Regular Expressions: Positive and Negative Lookahead // Help

Tell us what’s happening:
Hi, I have a problem with this challenge. I`m failing the following string

astr1on11aut

Does anyone have an idea why? I think that this part of the regex \d{2,} is troubling me.

Your code so far


let sampleWord = "astronaut";
let pwRegex = /(?=\w{5,})(?=^[^0-9]+\d{2,})/i; // 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/80.0.3987.149 Safari/537.36.

Challenge: Positive and Negative Lookahead

Link to the challenge:

Should’t your code be more Variable?
Also this link might help you out: https://www.rexegg.com/regex-quickstart.html

1 Like

here it is saying that there must be 1 or more non numbers followed by 2 numbers or more
instead astr1on11aut should pass, so you can’t put the limit that the first time you have numbers they must be at least two
the instructions says that there must be at least two consecutive numbers, there could be other numbers other than that

I have solved it in some strange way. Thank you for your help!