Give a regex, get a robust predicate function that tests it against a string.
npm install safe-regex-test