Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Regex: negative look ahead

by Anonymous Monk
on Apr 10, 2012 at 11:21 UTC ( #964311=note: print w/ replies, xml ) Need Help??

in reply to Regex: negative look ahead

This is because you did not understood the regular expressions at the fundamental level.

zero chars -> true -> after the current position is not (?!....) -> true -> return true

Use something like:

my $string = "ERROR blah license will expire"; if ($string =~ /^ERROR\b.+?(?:Error processing Cancel Execution|licens +e will expire)\b/m) { print "NOT MATCHED\n"; } else { print "MATCHED\n"; }
if ($string =~ /^ERROR\b/m and $string !~ /\b(?:Error processing Cance +l Execution|license will expire)\b/) { print "MATCHED\n"; } else { print "NOT MATCHED\n"; }

Comment on Re: Regex: negative look ahead
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964311]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2015-11-29 01:17 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (746 votes), past polls