Removed guard operator in front of clearTimeout call
Cached regex objects as variables outside of function call