in reply to RE: Re: Backwards searching with regexps
in thread Backwards searching with regexps

If it were up to me, I would immediately move to HTML::Parser instead of trying to craft a regexp by hand. You'll keep your hair longer. HTML::TokeParser is another good option.

Pragmatically, trying to match balanced tags (as HTML is supposed to be) with a regular expression is an exercise in futility for any data which you don't generate yourself, from another program. There are just too many corner cases which pop up surprisingly often.