Use typeof checking and use regex variable