in reply to Regex's on Text of HTML (using HTML::Parser)

Another option is HTML::TreeBuilder, which may be more suited towards your goal. Replacing existing tags can be tricky, given the dozens of variants that people may use in their HTML, some valid, most invalid. Let the module figure it out, not a hand-rolled regex.

merlyn has a recent article called "The Wrong Parser for the Right Reasons" which covers something very similar. Give it a read, and see if it suits your goal. A brief synopsis from the top of the article:

More and more these days, you get faced with a problem with angle brackets somewhere in the data. How do you find what you're looking for in HTML or XML data?

At first glance, the question has an obvious answer. If you have an HTML task, you use HTML::Parser or some derived or wrapper class. If you have an XML task, you use XML::Parser or XML::LibXML. But maybe the obvious answer isn't always the best. Let's look at a couple of cases.

  • Comment on Re: Regex's on Text of HTML (using HTML::Parser)