The best solutions are those where you use
someone else's code, exactly what
repellent,
gmargo and
CountZero suggested in response to your
previous query. This is specifically so you don't have to worry about variations and edge cases. For example, how do you know the html even conforms to the standard - browsers are notoriously forgiving of non-conformant hml. It's generally not a good idea to manually parse html or xml since regexes have a hard time with nested data structures. All of this is already handled in
HTML::TokeParser::Simple (or any of probably a dozen other HTML parsers on
CPAN).
If you are really motivated to use regular expressions, read perlretut and pay particular attention to non-greedy qualifiers.