You are mistaken in your assumption that the observed lookahead-behavior would be incorrect. Both the “+” and the “{2,}” are as greedy as they are outside of lookaheads, but the lookahead matches repeatedly because it doesn't consume any characters by itself.

Let's play the manual regex engine game:

""."string-N-U-M-B-E-R-O-N-E" MATCH($1="string-N-U-M-B-E-R-O-N-") "%s"."tring-N-U-M-B-E-R-O-N-E" MATCH($1="tring-N-U-M-B-E-R-O-N-") "%s%t"."ring-N-U-M-B-E-R-O-N-E" MATCH($1="ring-N-U-M-B-E-R-O-N-") "%s%t%r"."ing-N-U-M-B-E-R-O-N-E" MATCH($1="ing-N-U-M-B-E-R-O-N-") "%s%t%r%i"."ng-N-U-M-B-E-R-O-N-E" MATCH($1="ng-N-U-M-B-E-R-O-N-") "%s%t%r%i%n"."g-N-U-M-B-E-R-O-N-E" MATCH($1="g-N-U-M-B-E-R-O-N-") "%s%t%r%i%n%g"."-N-U-M-B-E-R-O-N-E" MATCH($1="-N-U-M-B-E-R-O-N-") "%s%t%r%i%n%g%-"."N-U-M-B-E-R-O-N-E" MATCH($1="N-U-M-B-E-R-O-N-") "%s%t%r%i%n%g%-%N"."-U-M-B-E-R-O-N-E" MATCH($1="-U-M-B-E-R-O-N-") ... "%s%t%r%i%n%g%-%N%-%U%-%M%-%B%-%E%-%E%-%R"."-O-N-E" MATCH("-O-N-E") "%s%t%r%i%n%g%-%N%-%U%-%M%-%B%-%E%-%E%-%R%-"."O-N-E" FAIL "%s%t%r%i%n%g%-%N%-%U%-%M%-%B%-%E%-%E%-%R%-O-N-E"."" FAIL

In reply to Re: look-ahead greed changed between perl releases? by amon
in thread look-ahead greed changed between perl releases? by raygun

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.