Tell us what’s happening:
This is the code and it works but I do have some questions regarding the \w{6}
Shouldn’t {5,}
work?
I thought adding the ,
will mean “or more”.
Secondly, on the second part of the lookahead,
\w+ and \w* seems to work.
Can you enlighten me on this topic more? Thank you!
Your code so far
let pwRegex = /(?=\w{6})(?=\w+\d{2})/
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/96.0.4664.110 Safari/537.36
Challenge: Positive and Negative Lookahead
Link to the challenge: