/*
Excercise 02
1. First 5 can be only characters
2. Next can be any number of Non digits
3. Last 2 characters should be digit
*/
let sampleWord = "astronaut12"
let pwRegex = /(?=\w{5})(?=\D*d{2})/
console.log(pwRegex.test(sampleWord))
Hello there, Where I am faltering I was expecting this to be true, but this is giving false.
After the first five I have used this: \D and then * so that after the first five there may be characters(0 to infinite), but the last two should be numbers.
The total string is not restricted to only “7” (Only 5 characters + 2 numbers), but the constraint is first five are characters and the last two are numbers.
I think that this can also be reduced to this one → let pwRegex = /(?=\w{5,})(?=d{2})/
/*
Excercise 02
1. First 5 can be only characters
2. Next can be any number of Non digits
3. Last 2 characters should be digit
*/
let sampleWord = "astronaut12"
let pwRegex = /(?=\w{5})(?=\D*\d{2})/
console.log(pwRegex.test(sampleWord))
//Simplyfying above regex
let pwRegex2 = /^\w{5,}\d{2}$/
console.log(pwRegex2.test(sampleWord))