Positive and Negative Lookahead on the \w*

Tell us what’s happening:
I felt as though I was very close to solving the challenge but then I gave up and looked at the solution. But even after analysing the solution, I couldn’t understand the need to have the shorthand \w*

So my confusion is to why that is necessary in this solution.

Anyone understand better than I do?

Your code so far


let sampleWord = "astronaut";
let pwRegex = /^\D(?=\w{5,})(?=\w*\d{2})/; // this is the solution
let pwRegex = /^\D(?=\w{5,})(?=\d{2})/; // this is what I believed to be correct
let result = pwRegex.test(sampleWord);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0.

Challenge: Positive and Negative Lookahead

Link to the challenge:

both lookaheads start looking from same position, this one is imposing that the digits are the second and third character of the string