in reply to Re: Multiple Regex evaluations or one big one?
in thread Multiple Regex evaluations or one big one?

If there's any backtracking, you have lost the first battle already.

The ultimate win when optimizing regular expressions is to keep the regular expression engine idle. To quote some Perl core hacker (Yves? Jarkko? Nicholas?), "Perls regular expression engine isn't fast. It often *looks* fast, but that's because the optimizer does such a good job". Splitting the pattern up in smaller parts increases the chance the regular expression can just stay in bed - and that the optimizer does all the heavy lifting.

  • Comment on Re^2: Multiple Regex evaluations or one big one?