$ perl -Mre=debug -le " $_ = q{this TON that}; m{this \s+ (?!NOT)\w+ \s+that}msgx; " Compiling REx "this \s+ (?!NOT)\w+ \s+that" Final program: 1: EXACT (3) 3: PLUS (5) 4: SPACE (0) 5: UNLESSM[0] (11) 7: EXACT (9) 9: SUCCEED (0) 10: TAIL (11) 11: PLUS (13) 12: ALNUM (0) 13: PLUS (15) 14: SPACE (0) 15: EXACT (17) 17: END (0) anchored "this" at 0 floating "that" at 7..2147483647 (checking floating) minlen 11 Guessing start of match in sv for REx "this \s+ (?!NOT)\w+ \s+that" against "this TON that" Found floating substr "that" at offset 9... Found anchored substr "this" at offset 0... Guessed: match at offset 0 Matching REx "this \s+ (?!NOT)\w+ \s+that" against "this TON that" 0 <> | 1:EXACT (3) 4 < TON that> | 3:PLUS(5) SPACE can match 1 times out of 2147483647... 5 | 5: UNLESSM[0](11) 5 | 7: EXACT (9) failed... 5 | 11: PLUS(13) ALNUM can match 3 times out of 2147483647... 8 < that> | 13: PLUS(15) SPACE can match 1 times out of 2147483647... 9 | 15: EXACT (17) 13 <> | 17: END(0) Match successful! Freeing REx: "this \s+ (?!NOT)\w+ \s+that"