If this were a Perl-only solution, or if the regex rarely changed, I would code it with a simple naive list, and then pass it once through Regex::Presuf for a little more efficiency. That module then figures out what common prefixes or suffixes can be coded more cleverly.