Reputation: 2228
<div class="myClass">
<form method = "post" name="loginForm" >
<input type="text" name="userName"/>
</form>
<form method = "post" name="signupForm" >
<input type="text" name="userName"/>
</form>
</div>
if this was to be an example html.
<div>(.*?)</div>
So, something like this, anything (even nested tags) between opening and closing div tag
Upvotes: 1
Views: 2251
Reputation: 1146
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>
Upvotes: 0
Reputation: 1148
Perhaps help you :
(<[div]+\s[a-zA-Z]+\=\"[a-zA-Z]+\">)(.*)(<\/[div]+>)
URL : https://www.regex101.com/
Upvotes: 1