Compile the regex once and just call it in function.
Add type to global var.