Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

regex: parsing out nested divs

807607Jan 26 2007 — edited Jan 27 2007
I have a dillemma.
I need to parse out nested divs, but i cant just have an expression like this:
String re = "(?i)(<div class=\"leftNavMenu\" id=\"leftNavMenu\">(.*?))<\\/div>)"
because this div may contain other divs, and a </div> tag from one of those will be matched.

I need to somehow keep track of balanced </div> tags. any ideas?

(other then using an html parser, because i am already waaaaaaaaaaaaaay over the deadline)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2007
Added on Jan 26 2007
24 comments
1,043 views