http://www.perlmonks.org?node_id=1008157


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

Actually I stand corrected: the fixed string prefixes are collected together into a trie where there are (possibly differing) wildcard suffixes; the killer is the individual captures, which disables the trie optimisation.

So, alternation is the fastest, as long as you put any captures outside the alt.

Dave.

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