SPUG: Regex question

Marc M. Adkins Perl at Doorways.org
Wed Apr 21 13:16:08 CDT 2004


Let's say I'm parsing HTML using regular expressions and I want to find:

        <tag> ... </tag>

where the text within the tag body does _not_ contain the word 'Alpo'.

I've seen the following as a solution:

        $text =~ m|<tag>(?:(?!Alpo).)*</tag>|;

This seems really compute-intensive.  Is there a better way?

mma


(test program attached)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dogfood.pl
Type: text/x-perl
Size: 882 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/spug-list/attachments/20040421/5d0810ba/dogfood.bin


More information about the spug-list mailing list