Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Negative Lookahead Assertion Strangness

by kvale (Monsignor)
on May 15, 2006 at 16:37 UTC ( #549541=note: print w/ replies, xml ) Need Help??


in reply to Negative Lookahead Assertion Strangness

In example 3, the lookahead assertion doesn't match at the beginning of the string, so the regex tries to match at the next position in the string, that fails and so on. This continues until the regex matches at position "oo then..." in which case no foo is found and it succeeds.

In example 4, the .* will first eat the whole string and then the foo will fail to match, satisfying the negative assertion :). So the whole string is printed.

Both of these examples show the danger of creating nonlocal assertions. It is easy to do something unexpected when the string tested is some distance from the assertion.

-Mark


Comment on Re: Negative Lookahead Assertion Strangness

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2014-12-26 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls