more generic; handles bad regexes