regex-adventure
regex-adventure copied to clipboard
incorrect regex passes on negated character class
in module #5 titled "negated character class", the tests don't cover an incorrect answer.
//CORRECT ANSWER: module.exports = function (str) { return /^[^0-9][^A-Z]/.test(str) }
//INCORRECTLY ACCEPTS: module.exports = str => /[^0-9][^A-Z]/.test(str)/
//AND: module.exports = str => /\D[^A-Z]/.test(str)
that means that the string does not have to start with a non-digit, just contain this sequence of two numbers somewhere within it.
you are right, i got this problem too