Use match() instead of search() for pattern matching

Also related to f48fa3, fix for #8614