Regulaf expressions

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

let sampleWord = "astronaut";
let pwRegex =  /(?=\w{6,})(?=\w*\d{2})/;
let result = pwRegex.test(sampleWord);

I didn’t know why to use \w* in the second parantheses
also why we used positive lookahead in the first parantheses since we want
and why we used positive lookahead in general since we want to match the password, in other words what is the pattern that we want to search for but not match

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.115 Safari/537.36

Challenge: Positive and Negative Lookahead

Link to the challenge:

because we’re checking strings like:


These are all the strings that contain 2 consecutive digits. So we have to prepend \d{2} with \w*

We’re just using lookaheads here to make sure that the string satisfies needed conditions.