|
|
|
Your skill will accomplish what the force of many cannot |
|
| PerlMonks |
Re: regex: negative lookaheadby kennethk (Monsignor) |
| on Dec 05, 2011 at 15:54 UTC ( #941884=note: print w/ replies, xml ) | Need Help?? |
|
If you take a look at what you have in $1 after your failed miss for 2, the issue will become more apparent, I think; print $1; yields log4j.rootLogger=INFO, FILE, SYSLOG. Essentially, you have already consumed ", SYSLOG" by the time you get to the end of the string, so clearly that bit does not follow. A negative look-behind will actually yield what you intended: print "has_matched $has\n" if $has =~ /^($start(\w+(,\s)?)+)(?<!$end)$/;
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||