Positive and Negative Lookahead---

Tell us what’s happening:
We can get the answer from the hint part but no one can really explain it, is it only me or we are many?

Your code so far


let sampleWord = "astronaut";
let pwRegex = /change/; // 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/86.0.4240.42 Safari/537.36.

Challenge: Positive and Negative Lookahead

Link to the challenge:

let quRegex= /q(?=u)/;
let qRegex = /q(?!u)/;

In the first a “u” must come after a “q”.
In the second a “u” must NOT come after the “q”.

1 Like