Regular Expressions - Positive and Negative Lookahead

Tell us what’s happening:

Hi, i’m not sure what does \D* part of my code contribute to the solution? Doesn’t \w{6,} already imply 6 or more characters?

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0

Challenge Information:

Regular Expressions - Positive and Negative Lookahead

Hi @mightmaster92

This part of the regex is looking ahead to find zero or more non digits followed by two numbers. So the two numbers can be at the end or in the middle of the string.

Happy coding

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