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


In reply to Re: look behind with multiple whitespace characters by Anonymous Monk
in thread look behind with multiple whitespace characters by RK

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.