Regular expression to match a chemical element
johndcook.com
johndcook.com
(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.)