JavaScript lazy regex for matching HTML tags
- by Grnbeagle
Hi,
I'm having a problem writing a regular expression for matching HTML tags. I found a similar entry here, but this didn't quite work in my case.
Here's my test string:
<div id="div0" class="myclass">here's some text
that may include whitespace</div><div id="div1" class="myclass">
and some more here
</div>
And here's my regex based on the aforementioned entry:
<div[^>]*class="myclass">[^~]*?<\/div>
Note that I need to match the first instance of <div /> with class of "myclass." The content may have carriage returns. These <div> tags won't be nested.
Here's a rubular page for testing: http://rubular.com/r/vlfcikKMXk