Lookahead in Regular Expression

Tell us what’s happening:
I am having trouble with this challenge. One of the test cases is “8pass99”, and I am not sure how to make sure only two consecutive digits are matched.

Your code so far


let sampleWord = 'astronaut';
let pwRegex = /^\D(?=\w{5})(?=\w*\d{2})/; // Change this line
let result = pwRegex.test(sampleWord);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36.

Challenge: Positive and Negative Lookahead

Link to the challenge:

Hi,

Remove ^and check again!

you are saying that the string should not start with a number, but there is not such a limit

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.