in reply to regex negative lookahead behaviour
You have to remember that the regex engine tries as hard as it can to make the match work.
"4 1/2 MILE RD" =~ m!(1/2)\s*(?!MILE)!;
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.";
|
|---|