How about just &#x2F;Ac|Ag|Al|Am...&#x2F;.  Let the regex compiler do the work for you, and keep it readable and maintainable.<p>(A true regular expression is compiled to a DFA, which is unique for the set of input strings matched, so there is nothing to gain performance-wise from factoring out common prefixes.  That is quite literally the job of the compiler.)