Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: Bug with finding all regexp matches

by Anonymous Monk
on Oct 15, 2016 at 19:07 UTC ( [id://1174082]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Bug with finding all regexp matches
in thread Bug with finding all regexp matches

I opened a bug on this, https://rt.perl.org/Ticket/Display.html?id=129886 .
  • Comment on Re^4: Bug with finding all regexp matches

Replies are listed 'Best First'.
Re^5: Bug with finding all regexp matches
by dave_the_m (Monsignor) on Oct 15, 2016 at 21:02 UTC
    This isn't a bug, it's intended behaviour :-). The superlinear cache kicks in for various types of complex/nested quantifiers (such as (z?)+) to avoid heat-death-of-the-universe time to find failure. It records pattern/string position combos where a match failed, and if it comes across the same combo again it stops and backtracks immediately at that point rather than continuing with the rest of the pattern (which will inevitably fail later).

    See the very first paragraph in perlre.pod about re_evals:

    B<WARNING>: Using this feature safely requires that you understand its limitations. Code executed that has side effects may not perform identically from version to version due to the effect of future optimisations in the regex engine. For more information on this, see L</Embedded Code Execution Frequency>
    Where that link goes to: Embedded Code Execution Frequency

    Dave.

      This isn't a bug, it's intended behaviour :-)

      Hmm, I see your point but AFAIU (*FAIL) itself doesn't add to regexp complexity and could be exempted from caching to allow (${ eval })(*FAIL) pattern to work as the doc itself suggests in other place. Still, my bug report landed next to others that are 4 years old, and given your comment I see where it will go...

      So, is there a way in Perl to find all regexp matches?

        (*FAIL) itself doesn't add to regexp complexity and could be exempted from caching
        Well it could (if at the top-level of a pattern), but that doesn't solve the issue - there are other regex optimisations (currrent or future) apart from the superlinear cache, any of which could potentially cause a match to "prematurely" fail.
        So, is there a way in Perl to find all regexp matches?
        I don't know, but I doubt it could be done reliably,

        Dave.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-16 07:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found