in reply to Re: alternation in regexes: to use or to avoid?
in thread alternation in regexes: to use or to avoid?

(I work with dk.)

Another question could be: why is the one with the capture groups so slow, since none of the words match the string?

And in general, why is alternation&capture so much slower than looping&capture + alternation combined?

The reason for the code is to replace code with 60 or so similarly structured regexes in a library used by a couple of legacy applications with an automatically generated regex generated with info from configuration files, for both (potential) performance gains, allowing different behaviour across applications, and definite maintainability gains. The strings replaced all have the structure \bFOO:\s*bar(\d+) or \bBAZ:\s*(\w+) etc.

Suggestions like "Well, don't do that" are likely to go unheard :-)

  • Comment on Re^2: alternation in regexes: to use or to avoid?

Replies are listed 'Best First'.
Re^3: alternation in regexes: to use or to avoid?
by RichardK (Parson) on Dec 10, 2012 at 16:08 UTC

    OK then, If you want to use a non-optimal solution for operational reasons, go right ahead :-)