in reply to regex in perl

Don't do that! Use any of the many modules designed for making a good job of parsing and manipulating markup like HTML and XML. HTML::Tree may be a good starting point.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond