Regular Expressions: Positive and Negative Lookahead - Help

Regular Expressions: Positive and Negative Lookahead - Help
0.0 0


So i’m on -->

I reworked te example and got this answer:

let sampleWord = "99etu";
let pwRegex =/(?=\w{3,6})(?=\D\d{2,})/i; // Change this line
let result = pwRegex.test(sampleWord);

I don’t get why the point of the \D? Is the pattern only going to work if the other one is present?


\D means no digit like A or J.

Check this thread for more detailed explination


Yeah but why is it in there in the first place? Why cant it just be the pattern of 2 or more numbers?


Well this /(?=\w{3,6})(?=\D\d{2,})/i is not the what challenge is looking for. It may passes the tests, but as you mentioned this \D looks redundant here, and of course it is.

Seems you just used one available default/sample pattern with some small changes that with luck it passed the tests.

This pattern you asked is wrong, check the thread link I shared the link it contains some detailed info about correct and expected pattern.


no one mentioned the challenge. why are you?


I’m sensing English isn’t your first language, you can use your native language.

(I’ll just use Google translate)