8pass99 seems to match even when I’ve assigned a first alphabet rule.
Please help me out if I’m making any mistakes with my input.
Your code so far
let sampleWord = "astronaut";
let pwRegex = /(?=[a-z]\w{5,})(?=\D*\d{2})/; // Change this line
let result = pwRegex.test(sampleWord);
console.log("8pass99".match(pwRegex));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36 Edg/81.0.416.62.
This is what I was using earlier for pwRegex, I hope this is what you meant by the entire string being checked to match the pattern. Using this failed a different case, as it was unable to match “astr1on11aut”. Please help me out with this issue.
your second lookahead is checking for “zero or more non digits followed by 2 digits”, which doesn’t consider that digits are allowed before the two consecutive digits. The parameters say “at least two consecutive digits”, not that those two consecutive digits must be the first in the string