Regular Expressions - Positive and Negative Lookahead

This is the answer, but I don’t understand why do I need to the /w* in the second part of this positive logahead?

let sampleWord = “astronaut”;

let pwRegex = /(?=\w{6,})(?=\w*\d{2})/gi;

let result = pwRegex.test(sampleWord);

Why do i need to use this shorthand again? Surely I should just be specifyinh that its two numbers, why do I need another \w

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.57

Challenge: Regular Expressions - Positive and Negative Lookahead

Link to the challenge:

Too long to explain again. Recycling answer from another post. :slight_smile:

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