Allow string == nil in hasMatchInString, and return false in that case.