http://qs321.pair.com?node_id=653746


in reply to Regex to match first html tag previous to text

I'd use HTML::TreeBuilder::XPath to find the nodes in question, then alter the values in the "DOM" and use methods from HTML::Tree to write the document back out.

Regular expressions are a very fragile solution to the "how do I parse HTML" problem.

-David