Positive and Negative Lookahead help please

In the code:

let password = "abc123";
let checkPass = /(?=\w{3,6})(?=\D*\d)/;

I do not know why they put D* in there, I mean they just want to have at least one number right, so to me having only \d is enough. Can you explain that to me.Thank you

Hey there! We can’t see your code right now.

1 Like

Hi, I have added my code in here

We are talking about this step?

for future: Try to provide links to challenges also

1 Like

yes, and I just want to ask about the second example, the D* regular expression part

\D means non-digit part of regular expression

lets do some deciphering
note: to my experience deciphering is effective method to learn regexps

\D >>> non digital character
\D* >>> zero or more non digital characters
\d >>> digital character

whole thing:

\D*\d >>>>>>> zero or more non-digits followed by digital character

Also. Consider to look into this topic

Oh, thank you, that a really really great answer :heart_eyes:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.