in reply to Regex: How do I use lookahead with search/replace?
(This is all a simplified case of what I'm actually trying to do.)If you are actually trying to do something more complicated than this, and if everything you're doing involves HTML or XML markup, then for the sake of your own sanity (and that of anyone else who might look at or work with your code), use an appropriate parser module (HTML::TokeParser, XML::Parser, or simple variants thereof) -- you'll see this advice repeated often at the monastery, and with good reason. Once you grok using one of these modules, the job will be easier, and there won't be any risk of duplicating tags by mistake with a regex.
update: I thought about posting some sample code, but decided not to, because you say the given example isn't exactly what you're really trying to do, and because the given example in itself doesn't really make sense -- it would seem more sensible if the intended output looked like this:
or like <b> <p> ... </p> </b> -- and when you use a parser module, this is the sort of modification that would be both natural and trivial to do.<p> <b> blah blah <blockquote> blah </blockquote> blah </b> </p>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regex: How do I use lookahead with search/replace?
by tunesmith (Initiate) on Feb 22, 2004 at 07:30 UTC | |
by graff (Chancellor) on Feb 22, 2004 at 08:27 UTC | |
by tunesmith (Initiate) on Feb 22, 2004 at 09:50 UTC |