Run it through rxrx and see what happens, or even $ perl -Mre=debug -e" $_ =qq{foo bar \ntest}; m/(?<!foo)\s+bar\s+t
+est/g "
Compiling REx "(?<!foo)\s+bar\s+test"
Final program:
1: UNLESSM[-3] (7)
3: EXACT <foo> (5)
5: SUCCEED (0)
6: TAIL (7)
7: PLUS (9)
8: SPACE (0)
9: EXACT <bar> (11)
11: PLUS (13)
12: SPACE (0)
13: EXACT <test> (15)
15: END (0)
floating "test" at 5..2147483647 (checking floating) minlen 9
Guessing start of match in sv for REx "(?<!foo)\s+bar\s+test" against
+"foo bar %ntest"
Found floating substr "test" at offset 12...
Guessed: match at offset 0
Matching REx "(?<!foo)\s+bar\s+test" against "foo bar %ntest"
0 <> <foo bar> | 1:UNLESSM[-3](7)
0 <> <foo bar> | 7:PLUS(9)
SPACE can match 0 times out of 21474
+83647...
failed...
1 <f> <oo bar > | 1:UNLESSM[-3](7)
1 <f> <oo bar > | 7:PLUS(9)
SPACE can match 0 times out of 21474
+83647...
failed...
2 <fo> <o bar > | 1:UNLESSM[-3](7)
2 <fo> <o bar > | 7:PLUS(9)
SPACE can match 0 times out of 21474
+83647...
failed...
3 <foo> < bar %n> | 1:UNLESSM[-3](7)
0 <> <foo bar> | 3: EXACT <foo>(5)
3 <foo> < bar %n> | 5: SUCCEED(0)
subpattern success...
failed...
4 <foo > < bar %nt> | 1:UNLESSM[-3](7)
1 <f> <oo bar > | 3: EXACT <foo>(5)
failed...
4 <foo > < bar %nt> | 7:PLUS(9)
SPACE can match 3 times out of 21474
+83647...
7 <o > <bar %ntest> | 9: EXACT <bar>(11)
10 < bar> < %ntest> | 11: PLUS(13)
SPACE can match 2 times out of 214
+7483647...
12 < bar %n> <test> | 13: EXACT <test>(15)
16 < bar %ntest> <> | 15: END(0)
Match successful!
Freeing REx: "(?<!foo)\s+bar\s+test"
First it matches "foo" which isn't allowed, but then it matches "foo " which is allowed since its not "foo"
Basically, you need to rethink what you're trying to achieve, see Look Behind issues |