escapeForRegex function, query object function