Regex To Match All Characters Wrapped In A Div Tag
Solution 1:
Perhaps help you :
(<[div]+\s[a-zA-Z]+\=\"[a-zA-Z]+\">)(.*)(<\/[div]+>)
URL : https://www.regex101.com/
Solution 2:
I had to do this a few years ago, but with additional flexibility (capturing content of no matter what element):
<(?<element>\w+).*?>(?<content>.*)?</[\s]*\1>
Which works quite okay, but I have to agree with the comments above; if you can, use a fully fledged DOM parser! It'll handle edge cases etc...
Not if you really just want to get content of <div />
's that would be:
<(div).*?>(?<content>.*)?</[\s]*\1>
Post a Comment for "Regex To Match All Characters Wrapped In A Div Tag"