Nested Regex Targets

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
GameMusic
Forum Newbie
Posts: 24
Joined: Fri Oct 28, 2005 8:33 pm

Nested Regex Targets

Post by GameMusic »

I ran into this problem when making an HTML filter. When searching for HTML tags, how do you handle nesting?

For example, if I search for all HTML tags, <b><i></i></b> is straightforward with ungreedy matching, but <b><i><b></b></i></b> will match the nested closing b tag with the first b tag. To get around this I made a ridiculously complex system with regexes that marked tags with numbers and recursive callbacks. Now I'm making a template system, and need to allow nested template markup, and something that slow isn't an option.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the following links may be of interest:
viewtopic.php?t=42897
viewtopic.php?t=26359
Post Reply