I've got a regex problem and I've reduced it to this code:
const ENV_NAME_REGEX = '[a-zA-Z_]+[a-zA-Z0-9_]*'
const array = ["VALID", "9INVALID"]
array.forEach((item) => {
const valid = new RegExp(ENV_NAME_REGEX).test(item)
console.log(valid)
})
Actual output:
true, true
Expected output:
true, false
The second item in the array doesn't match the regex right (because the first char cannot be a number). So why is it outputting both as true?