Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: regex: negative lookahead

by vinian (Beadle)
on Dec 06, 2011 at 05:01 UTC ( #941957=note: print w/ replies, xml ) Need Help??


in reply to regex: negative lookahead

i don't think there is something to do with regex negative lookahead, the problem lies in the
(\w+(,\s)?)+
it will match "INFO, FILE, SYSLOG", but not "INFO, FILE".
"+" is greedy, it eaten whatever match by "( ... )" . I don't how to make the above regex match less, but i use this
print "has_matched $has\n"    if $has   =~ /^($start(\w+(,\s)?)+?)$(?<!$end)/;
and it will not match $has.


Comment on Re: regex: negative lookahead
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-07-24 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (155 votes), past polls