RegEx Positive and Negative Look-ahead wrong answer?

Hello,

First off, as it is my first post here, let me say that I am enjoying learning with freeCodeCamp and I think completing my journey here will let me accumulate some really solid foundations for my future coding career :slight_smile:

To the point: in the Regular Expressions: Positive and Negative look-ahead the suggested answer

let pwRegex = /^(?=\w{6,})(?=\D*\d{2})/ is in my opinion in conflict with one of the conditions stated in the question : Use lookaheads in the pwRegex to match passwords that are greater than 5 characters long, do not begin with numbers, and have two consecutive digits.

It allows passwords like “123john” to pass, because the first part of the RegEx accepts all alphanumericals at the beginning of the string. I’ve changed it to: let pwRegex = /^(?=[a-z])(?=\w{6,})(?=\D*\d{2,})/i and now it works as intented.

If I’m wrong please correct me, cheers!