Positive and Negative Lookahead help plz

Tell us what’s happening:

can someone explain the usage of \w and the usage of \D*\d

Your code so far


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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead

Try the awesome tool: https://regexr.com/
Copy paste the expression and you’ll find an explanation for every single part of your regular expression. If you click on them, you’ll even find examples!
And if it is still fuzzy, you can always come back here!

Thank you so much! Helped a great deal.

I’m glad to hear it!
Happy learning!
:wink: