I have one error for the Positive & Negative Lookahead challenge, but I am not sure how to fix it. “8pass99” should not match but it does. I know it’s because matching passwords aren’t supposed to start with a number, but I am not sure how to fix my code.
Looking forward to some help on this one!
Your code so far
let sampleWord = "astronaut";
let pwRegex = /(?=\w{6,})(?=\D+\d{2})/; // Change this line
let result = pwRegex.test(sampleWord);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.
I feel like I am getting closer with the answer below:
/^\D(?=\D*\d{2,}$)(?=\w{5,})/
But, I am still getting the following error: "Your regex should match “astr1on11aut”. I believe it’s because the numbers aren’t at the end of the string and I’ve made my digits necessary for the end. However, I get the same error if I test the code below.
this says 0 or more non numbers followed by at least two numbers
but the “at least two consecutive numbers” doesn’t mean that can’t be other numbers in the string, instead you are imposing that those must be the first ones
I am having trouble with the exercise, I found a solution which unfortunately is failing on one pass and that is th3 “8pass99” whereas the rest are passing without fail.