Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: regex: negative lookahead

by svenXY (Deacon)
on Dec 05, 2011 at 16:08 UTC ( #941887=note: print w/ replies, xml ) Need Help??


in reply to Re: regex: negative lookahead
in thread regex: negative lookahead

Hi,
++kennethk - thanks for clarifying. I'm still a little bit confused by the difference between (?!...) and (?<!...) though.
Regards,
svenXY


Comment on Re^2: regex: negative lookahead
Re^3: regex: negative lookahead
by kennethk (Monsignor) on Dec 05, 2011 at 16:38 UTC
    The difference is a lookahead versus a lookbehind. If you ignore the lookahead/lookbehind because they are zero width (don't consume characters), you would expect /^($start(\w+(,\s)?)+)$/ to grab an entire string between start and finish. When you get to the part of the regular expression where you have your assertion, the cursor is here:
    log4j.rootLogger=INFO, FILE, SYSLOG ^
    If you look ahead of this position, there is nothing, which clearly passes the negative lookahead check. The offending string is behind your position, thus you need a negative lookbehind.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-08-21 22:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (144 votes), past polls