Positive and Negative Lookahead Please help

Positive and Negative Lookahead Please help
0

#1

Hi guys, I just did this challenge and by some dumb luck I managed to get it right, but I dont understand how this checks for 2 consecutive digits… The rest I get but I dont want to go that much foward without understanding this.

Your code so far


let sampleWord = "astronaut";
let pwRegex = /(?=\w{5,})(?=\D*\d)/; // 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/68.0.3440.106 Safari/537.36.

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


#2

You can check for 2 consecutive digits using curly brackets you used earlier like this

d{2,}