Hello, I was having some trouble understanding lookaheads when used with other code.
Breaking it down, from my understanding, the first lookahead is stating that there must be 6 alphanumerics (including _).
The first part of the second lookahead says that its looking for 0 or more alphanumerics. But why do this if the first lookahead already finds 6.
The second part of the second lookahead says its looking for two or more consecutive numerical numbers. And since this is the second lookahead, does it have to be at the end or no because it doesnt have the $ at the end.
And what’s the point of having two separate lookaheads instead of all in one (I know that the code wont work).
I personally dont like this method of checking passwords, I prefer the way they made us do it in a previous challenge
Your code so far
let sampleWord = "astronaut";
let pwRegex = /(?=\w{6})(?=\w*\d{2})/;
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/94.0.4606.81 Safari/537.36 Edg/94.0.992.50
Challenge: Positive and Negative Lookahead
Link to the challenge: