Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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

Replies are listed 'Best First'.
Re^3: regex: negative lookahead
by kennethk (Abbot) 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?
[karlgoethebier]: ...because of sausage and luncheon meats...
[karlgoethebier]: ... the ultimate coding experience for everyday people...
[karlgoethebier]: ...like me
[marto]: what a mess
[karlgoethebier]: perhaps i need a zerial?
[Corion]: marto: Heh - I think that's a nice contractual trap, "you will not use other gods/engines besides ours" ;)
[Corion]: But if the base intention was to have CIG as "co-developers" who (have to) contribute changes back to the mainline, it makes sense to have them use no other engine
[marto]: yes, I hear that development house has been on its last legs for a couple of years now

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2017-12-14 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (389 votes). Check out past polls.

    Notices?