Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^3: On zero-width negative lookahead assertions

by Crian (Chaplain)
on Sep 10, 2004 at 14:51 UTC ( #390099=note: print w/ replies, xml ) Need Help??

in reply to Re^2: On zero-width negative lookahead assertions
in thread On zero-width negative lookahead assertions

> But I can't understand why it doesn't work if you put the \s* outside the parens, nor I can understand why it stops working if I put the \s*$ at the end of the regex :-(

That is because if you have the string

root: 11111233333333333333333333

and the RE

/^root:\s*(?!\s*admin\@somewhere\.here)/ ABBBBBCCC

then the part A in the RE matches the beginning of the string, part BBBBB matches 11111 ("root:") and CCC matches an empty string (not a space, a string with zero chars in it). After this empty string follows a space, and the space is not the beginning of "", because it is the beginning of "".

I hope things are getting clearer for you :-)

Comment on Re^3: On zero-width negative lookahead assertions
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2015-11-24 23:36 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 (665 votes), past polls