Optimized the regular expressions.