Tell us what’s happening:
my code is not passing the challenge. How can i match at least two consecutive digit at the end the password “abc123”

Your code so far

let sampleWord = “abc123”;
let pwRegex = /(?=[a-z]{1-5})(?=\d)/ig; // Change this line
let result = pwRegex.test(sampleWord);


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Positive and Negative Lookahead

Link to the challenge:

first, if {1-5} is saying the number of times it should be, then you need to review that syntax because it doesn’t work like that
then you need to know that if you have two lookheads or lookbehinds they start from same position
at this time you have two lookaheads that are in contrast: one say to have letters and the other numbers in the same place

1 Like