. . . except that you also need to account for closing tags that aren't nested properly. For instance, in the following example, using that simple stack approach would give you extra closing tags:
Try <i><b>this</i></b> on for size.
Instead of fixing improper nesting, a straight-up stack matching approach would give you this:
Try <i><b>this</b></i></b> on for size.
It's also probably best these days to stick to valid XHTML, which means that all tags get closed (for instance, use <hr /> instead of <hr>).
print substr("Just another Perl hacker", 0, -2); |
|
- apotheon
CopyWrite Chad Perrin |