Regular Expressions: Positive and Negative Lookahead, extra ()?

Regular Expressions: Positive and Negative Lookahead, extra ()?
0

#1

So I recently completed the challenge…
“Use lookaheads in the pwRegex to match passwords that are greater than 5 characters long and have two consecutive digits.”

Due to a little help from the forums. The answer that worked was “/(?=\w{6,})(?=(.\d{2,}.))/”

That whole thing makes perfect sense to me, but what confuses me is why the 2nd check needs a 2nd pair of parenthesis. I couldn’t find a reason for it, and it’s probably in plain site, but the first check doesn’t use it and every example of this challenge I saw had the extra parenthesis on it…

Does anyone have a good explanation for this?


#2

Please note /(?=\w{6,})(?=(.\d{2,}.))/ is not correct, check this thread which comes with correct regex, and explination.