Replacing brittle string checking with regex.