go ahead... be a heretic | |
PerlMonks |
Re: regex negative lookahead behaviourby sauoq (Abbot) |
on Jul 18, 2003 at 17:15 UTC ( [id://275685]=note: print w/replies, xml ) | Need Help?? |
You have to remember that the regex engine tries as hard as it can to make the match work.
First, the engine slurps up all the space after the "1/2" with the \s* and finds that it doesn't match because of your assertion. Next, it backtracks by slurping all but one space with the \s*. At that point, your assertion "MILE" doesn't match " MILE" (with a leading space) so it is successful. -sauoq "My two cents aren't worth a dime.";
In Section
Seekers of Perl Wisdom
|
|