in reply to Regex within html
What I'd recommend instead is to tokenize your text, that is split it up into chunks that are 1) either normal text or 2) your special comments or 3) opening or closing <a> tags.
Then iterate over all these chunks, and count the difference in the number of opening and closing anchor tags. While iterating over these tokens you construct an output string, and in that string it shouldn't be too hard to get the nesting of <a> tags correctly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex within html
by ropey (Hermit) on Sep 08, 2008 at 12:38 UTC | |
by moritz (Cardinal) on Sep 08, 2008 at 13:08 UTC | |
by Anonymous Monk on Sep 08, 2008 at 12:43 UTC |