I don't really understand Positive and Negative LookaheadPassed

Tell us what’s happening:

Hello ! I have some problems with RegExp. I solve this challenge but why this code does not work : /(?=\w{5,})(?=\w*\d{2})/ ? Can someone explain me the meaning of this solution below ? Thanks
Your code so far

let sampleWord = "astronaut";
let pwRegex = /(?=\w{6})(?=\w*\d{2})/; // 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/90.0.4430.72 Safari/537.36.

Challenge: Positive and Negative Lookahead

Link to the challenge:

The only error with your code is the {5,} part. The challenge states match passwords that are greater than 5 characters long. So it must be 6, as 5 is not greater than 5.

1 Like

I thought {5} means equal 5 and {5,} means more than 5. thanks for your response

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