Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: look-ahead greed changed between perl releases?

by sn1987a (Chaplain)
on May 06, 2014 at 16:33 UTC ( #1085205=note: print w/replies, xml ) Need Help??


in reply to look-ahead greed changed between perl releases?

Your reported behaviour in 5.16.3 is what I expect. I do not have a 5.12.4 handy to test.

The look ahead is zero-width which means it does not consume any of the input. The regexp matches starting which the s so a % is placed before it. The regexp engine then resumes searching, at the next character and matches starting at the t. This process repeats until there is not enough hyphenated upper case letters to match.

Replies are listed 'Best First'.
Re^2: look-ahead greed changed between perl releases?
by raygun (Beadle) on May 06, 2014 at 18:15 UTC
    So that overrides the greediness precept? The perlre document isn't clear on this, so I wasn't sure which behavior was considered correct.

    I no longer have a 5.12.4 handy either: I discovered this issue after upgrading perl and finding my code was no longer working as it had before. Was this a bug in a 5.12.4? I can't find anything in the perl*delta docs that lead me to believe this is an intentional behavior change.

      No, it does not override the greediness. The regexp still matches that longest string. But this is just a look ahead. Once the match/substitution is made, the regexp engine starts searching again after the first character matched.

      amon below has a great graphical view of what is happening (Re: look-ahead greed changed between perl releases?).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1085205]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2019-04-21 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (110 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!