my $test = q{ <a href="detail.jsp?key=7147&rc=d_20071128&p=2&pv=1">Next Page</a><br/> <a class="foot" href="email.jsp?key=7147">E-mail Story</a> }; print "BEFORE: $test\n\n"; $test =~ s{<a[^>]+>.*?e-?mail[^<]*</a>}{}gim; print "AFTER: $test\n";
That strips them outright, but probably you should not use it. It's naive and it will break (like most all regex-based markup parsing). What you want to do is either what erroneousBollock said, or I use XML::LibXML for XHTML. There are many other options in the X(HT)ML space. If you have dirtier HTML, those won't work. You can also do it in a stream with HTML::TokeParser.
In reply to Re: Regex to match first html tag previous to text
by Your Mother
in thread Regex to match first html tag previous to text
by Greebo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |