in reply to look behind with multiple whitespace characters

The regex  qr{(?<!foo)\s+bar} will not match
          'foo    bar'
              ^^
              ||
   no match --++-- can match here
at the first position because it's preceded by 'foo', but at the second position it's not preceded by 'foo' but by a whitespace character, so it can match!

Update: If you have Perl version 5.10+, here's one way to simulate a variable-width negative look-behind:

c:\@Work\Perl>perl -wMstrict -le "use 5.010; ;; my $s = 'foo 1 foo 2 foo 3 4 x 567 foo foo 8 foo9'; my @matches = $s =~ m{ (?> foo \s+ \d+ (*SKIP)(*FAIL))? \s+ \d+}xmsg; printf qq{'$_' } for @matches; " ' 4' ' 567'
See Special Backtracking Control Verbs in perlre for  (*SKIP) (*FAIL) and friends.
See also Look Behind issues and Another Look behind for further recent discussion of the variable-width negative look-behind issue. (Update: Variable-width positive look-behind is nicely handled by the  \K operator.)


Give a man a fish:  <%-(-(-(-<