Positive and Negative Lookahead helpp

Positive and Negative Lookahead helpp
0.0 0


Need help with this challenge

Your code so far

let sampleWord = "astronaut";

let pwRegex = /(?=\w{5,})(?=[0-9]+)/; // Change this line
let result = pwRegex.test(sampleWord);

Your browser information:

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

Link to the challenge:


you need 2 consecutive digits but your regex only checks that you have 1 (+ means 1 or more) …
can you think of a way to check for 2?

hint: the solution (as I recall) is very similar to the example


I haven’t got this far in the JS section but when I tried the example by changing the {3,6} to {5}, it worked.


i did a little thinking and i applied the code in which you have to match atleast one digit but i really cant fully understand what is going on in the second lookahead


the second look-ahead says:

Tell me if the string has any number of non-digit characters followed by two digit values

(\D* any number of non-digits)
(\d\d exactly two digits)