ensure the attribute is a string before trying to run the regex match on it