You might want to do a benchmark ```in_array``` vs ```preg_match``` where ```$validCharacters``` is a pattern.