1
<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

Mefhisto1
  • 2,188
  • 7
  • 34
  • 73
  • 7
    Please don't parse HTML with regex. Use a DOM parser (depends on the language you have). See what happens to those who do: http://stackoverflow.com/a/1732454/871050 – Madara's Ghost Jan 14 '15 at 09:07
  • 2
    Use Html Agility Pack http://htmlagilitypack.codeplex.com/ to parse HTML, not regex! – RePierre Jan 14 '15 at 09:18

2 Answers2

1

Perhaps help you :

(<[div]+\s[a-zA-Z]+\=\"[a-zA-Z]+\">)(.*)(<\/[div]+>)

enter image description here

URL : https://www.regex101.com/

A.A
  • 1,138
  • 1
  • 16
  • 29
0

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>
pysco68
  • 1,136
  • 9
  • 15