in reply to Negative Lookahead Assertion Strangness
Four says /(?!^.*foo)(.*bar.*)/), which asks "does there exist the leftmost place in the string where we can look ahead and not see the begining of the string (followed by other stuff), and then some "bar" later (which is captured)?" And yes, as soon as we leave the beginning of the string, we can no longer "look forward to see the beginning of the string". So it matches right after the first char.
If you are careful about how you read the regex, it'll become clear what it's trying to match and capture. You just have to be careful. :)
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Negative Lookahead Assertion Strangness
by Fletch (Bishop) on May 15, 2006 at 17:32 UTC |