Tell us what’s happening:
I don’t understand why I need the “\D*” section of line 2 (let pwRegex…)
In my mind, this second positive lookahead should only be looking for 2 digits, ie…
let pwRegex = /(?=\w{5,})(?=\d{2})/i;
But then it says it doesn’t match “bana12”. bana12 has 5 or more alphanumeric characters, and it has 2 consecutive digits.
Help me understand what I’m clearly missing??
Your code so far
let sampleWord = "astronaut";
let pwRegex = /(?=\w{5,})(?=\D*\d{2})/i; // Change this line
let result = pwRegex.test(sampleWord);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge:
/learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead