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
Caroline
Your code so far
let sampleWord = "12345";
let pwRegex = /(?=\w{6,})(?=\D*\d{2})/; // Change this line
let result = pwRegex.test(sampleWord);
console.log(result)
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.