The exercise describes it as “and at least one number”.
So in addition to the first lookahead wanting 3-6 characters, the second one makes sure that there is at least one number in there.
I understand what it accomplishes, I don’t understand why this expression makes sure that there is at least one number present.
\d represents [0-9]
\D represents [^0-9]
So \D* returns 0 or more of everything except a digit and \d returns a digit.
Why is \D* needed? why not just \d?
While typing this I start to understand the expression. (?=\D*\d) is asking for 0 or more of any characters AND 1 digit. So to put it all together, /(?=\w{3,6})(?=\D*\d)/ is an expression that looks for:
A string with at least 3 characters, and at most 6 characters