This answer would be more relevant if the original poster were actually asking how to parse HTML. But this is not what the original poster asked; using HTML::Parser to perform a straightforward substitution like this, on HTML that is known ahead of time, would be overkill. I think the fact that my regex met the original poster's needs is sufficient proof of this.