Replace bad regex with a substring test