You might be better off using HTML::Parser to parse
out HTML tags, then apply your regular expression
on a tag-by-tag basis. It will be very difficult to get your
regular expression to work properly considering the variety
and complexity that can occur in an HTML document.