What is the difference between (?=\d{2}) and (?=\D*\d{2})?

Tell us what’s happening:
Describe your issue in detail here.
Is there any relationship between the matching ranges of expressions enclosed in parentheses before and after?

Your code so far

let sampleWord = "1astronaut11";
let pwRegex = /(?=\w{6,})(?=\d{2})/; // Change this line
let result = pwRegex.test(sampleWord);
console.log(result);

Your browser information:

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

Challenge: Positive and Negative Lookahead

Link to the challenge:

The two look ahead match the same position, if you write this

You are saying that of the 6+ characters matched by the first lookahead, the first two must be numbers

1 Like

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