Tell us what’s happening:
why the need for the two positive lookahead. i need explanations on what each lookahead is doing.
also, whats the need of non digit (D+) before /d
also, ^\w is alphanumeric. which means alphabet or a number can be at the front of the string. but the challenge said do not start with number.
Your code so far
let sampleWord = "ban56fadrrr57";
let pwRegex = /^(?=\w{5,})(?=\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 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 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