Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re (tilly) 1: Avoiding regex backtracking

by blakem (Monsignor)
on Mar 13, 2002 at 02:52 UTC ( [id://151290]=note: print w/replies, xml ) Need Help??


in reply to Re (tilly) 1: Avoiding regex backtracking
in thread Avoiding regex backtracking

This snippet shows very different behavior in 5.6.1 and 5.00503. In the earlier version I see the exponential execution time, but in 5.6.1 it seems to do *much* better. Do you know of any improvements in perl that might account for this?

-Blake

  • Comment on Re: Re (tilly) 1: Avoiding regex backtracking

Replies are listed 'Best First'.
Re (tilly) 3: Avoiding regex backtracking
by tilly (Archbishop) on Mar 13, 2002 at 03:37 UTC
    Yes.

    In 5.6 the engine keeps track of how long "complex RE's" are taking to match. If it is too long, then it redoes it while keeping a history of visited positions. This will reduce the worst case scenario from exponential to polynomial (unless, of course, you use backreferences).

    There is, however, an optimization that I know of which would turn this into straight linear behaviour. I gave a basic sketch of the idea at Re (tilly) 1: Research ideas, but to the best of my knowledge nobody has ever implemented it in any real RE engine...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 22:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found