Tell us what’s happening:
My regex should match astr1on11aut, but I’m wondering why what I have doesn’t work and if there’s a small change I could make to it fix it without having the same solution that’s provided on FCC.
Your code so far
let sampleWord = "banan1";
let pwRegex = /(?=^\D)(?=\w{5,})(?=\D*\d{2})/; // Change this line
let result = pwRegex.test(sampleWord);
// pwd > 5, no beginning number, two consecutive
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0.
your last lookahead, you are imposing “zero or more non digits followed by two digits” but you shouldn’t impose that the two digits are the first digits in the string
but then I get 3 fails. How exactly does the program view these statements? I understand this to mean "check at the beginning of the string for anything that’s not a digit or zero characters followed by two digits and check to see if the string is at least 5 characters
exactly, but that means that there can’t be other numbers before the 2 conseuctive numbers because you are using \D
so astr1on11aut will fail because you have non digits, a digit, non digits and then finally the two consecutive digits
instead you need to have astr1on11aut accepted by your regex