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!

@KJ86 Welcome to the Free Code Camp forum. Glad to hear you are enjoying the curriculum.

Would you mind bringing up this issue on this outstanding PR where this challenge is being worked on?

EDIT: A new solution was suggested on the PR I referenced above that addresses the issue you brought up. Once that PR is merged, we will update the solution on the forum’s hints/solutions page for the challenge.