More issues with Regex

Tell us what’s happening:
Hello all, I just want to make sure that I am following the logic properly in this regex. Please let me know if I am interpreting this answer the wrong way.

So this regex will first search to make sure that there is a pattern with 6 or more characters in it which includes capital and lowercase letters as well as numbers. Then the second part is setting another condition for the lookahead to have characters that are not numbers in a row followed by at least two numbers afterwards.

Is this correct or did I miss something.

If this is correct, would it be a mistake to think of this regex as a if it was an if statement with another if statement nested inside it?

So the first

Your code so far


let sampleWord = "banan1";
let pwRegex = /^(?=\w{6,})(?=\D+\d{2})/; // Change this line
let result = pwRegex.test(sampleWord);
console.log(result);

Your browser information:

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

Challenge: Positive and Negative Lookahead

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead

You could think of these two lookaheads as two conditions in a single if statement that have the && operator between them.

1 Like