steves has asked for the wisdom of the Perl Monks concerning the following question:
Okay, just when I feel like a Perl-meister, I get stumped by this seemingly innocent regex match that uses a lookahead assertion:
use strict; my $test = '<p> ONE <p> TWO features: <ul> THREE'; my ($first, $second, $third) = ($test =~ /(<p> )(.+(?!<p>))(features\: + <ul>)/i); print "1: $first\n"; print "2: $second\n"; print "3: $third\n";
Output is:
1: <p> 2: ONE <p> TWO 3: features: <ul>
I was expecting only TWO for the second match since there's an intervening <P>. Some monk please humble me here.
Back to
Seekers of Perl Wisdom