Optimized Regex

Optimized Regex to remove some if statement calls.