Don't understand this regex exercize

Tell us what’s happening:
I am confused about this excercize. I don’t understand why do we have to put \D* before \d{2}
I think I misunderstand something…

Thank you for your help

Your code so far

let sampleWord = "12345";
let pwRegex = /(?=\w{6,})(?=\D*\d{2})/; // Change this line
let result = pwRegex.test(sampleWord);

Challenge: Positive and Negative Lookahead

Link to the challenge:


This means “is there a pattern that uses 3-6 alphanumeric characters?”


This means “is there a pattern that matches non-digit character, followed by [*], followed by a digit?”

Did that clarify anything?

Edit - mistake on my part, corrected

Just to be clear, /\D*\d/ is not looking for the asterisk character. In this case, the asterisk is a “quantifier”, it is saying that of those \D (non-digit) characters, there can be anywhere from 0 to “whatever” before the \d (digit) character. So, this would match:

Yeah, regex is confusing. But it’s also really cool and really powerful. When in doubt I like to hop on a regex playground like this (or something like it) and mess around. It does a good job of explaining what the different parts do and let you experiment to see what will get caught by that regex.

Thank you very much, I now understand!