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


in reply to Re^2: Unefficient Regexp 'Matching this or that'
in thread Unefficient Regexp 'Matching this or that'

Another idea: The regex engine has a heavy optimization for looking for literal substrings, using the same algorithm that index uses.

In the case of one literal that can be used, but I don't think it's used in alternations.

You can test this hypothesis by comparing regexes of two and three alternatives - if I'm right, then both should be roughly equal in speed, and much slower than a single, literal string.