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

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...

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