Why the second positive lookahead working(I wasn't able to understand the logic behind the second one)?

I want to know what’s the logic behind the second positive lookahead ? :sweat_smile:

Your code so far

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

Your browser information:

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

Challenge: Positive and Negative Lookahead

Link to the challenge:

(?=\w*\d{2}) makes sure there are two consecutive digits(within a match that can have other symbols in front)

hey buddy I’ve completed this task the only thing I want to know is that, how the second positive lookahead is working ??

im not sure what you mean. The regex makes sure both lookaheads apply to the password. The first lookahead requires 6 symbols, the second requires at least 2 consecutive digits

1 Like

yep that’s exactly what i’m asking , so the second one requires at least 2 consecutive digits !

yes, that is what i stated in my initial post ^^

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