assuring the query is an string before evaluating a regex