Allowing only certain inputs based on a regex pattern