Why ?=\d\d is not working

Tell us what’s happening:
I dont get it. other answers on forum didnt provide any meaning to me.
So, I have this task:
‘Use lookaheads in the pwRegex to match passwords that are greater than 5 characters long, do not begin with numbers, and have two consecutive digits.’
And I dont understand why is it failing ‘bana12’ if I have an expression for it: (?=\d\d)
Why it fails?

Your code so far

let sampleWord = "astronaut";
let pwRegex = /(?=^[a-z])(?=\w{5,})(?=\d\d)/; // Change this line
let result = pwRegex.test(sampleWord);

**Your browser information:**

User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36</code>.

**Challenge:** Positive and Negative Lookahead

**Link to the challenge:**

the lookaheads start looking from the same position, should the number be at the start? or can they be anywhere?

oh, I got it, thank a lot

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.