Tell us what’s happening:
in the second lookahead \D* or \w* is required. But why?
Even in the explanation \D* is used for the password. why?
i dont get it…
(?=\w{6,})(?=\D*\d{2,})
The first lookahead (?=\w{6,}) searches for numbers, alphabets and space that appears more than 5 times.
The second lookahead (?=\D*\d{2,}) searches for non numbers that appear zero or more times. And searches for numbers that appear twice.
that what i understand.
Your code so far
let sampleWord = "astronaut";
let pwRegex = /(?=\w{6,})(?=\D*\d{2,})/; // Change this line
let result = pwRegex.test(sampleWord);
console.log(result);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Challenge: Positive and Negative Lookahead
Link to the challenge: