only seems to check for 2nd lookahead (\d\d+) WITHIN the 1st 6 characters. (something to do with the first lookahead?)
if i put 2 \d’s in from 7th(ish) character, no match! but the first 6 and it’s a match!
also, if i remove the first lookahead, the \d\d+ works throughout.
any clue as to why much appreciated.
Your code so far
let sampleWord = "3a3n6n88n83";
let pwRegex = /(?=\w{6,})(?=\d\d+)/gi; // Change this line
let result = pwRegex.test(sampleWord);
console.log(result)
FALSE*
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36
am i?
you mean the leading 2 character from the first lookahead?
because i dont think that’s how it’s working.
(if there are 2 consecutive digits in the trailing 2 (or any) of the first lookahead, it gives ‘true’. (but not in succeding characters of original string))
the first lookahed says 6 or more characters
the second one says \d\d+, as the two lookaheads start from same position, the 6 characters matched by first lookahead must be digits
oh,
the lookahead is like a whole regex on it’s own…so you have to deal with the start of the string and work forwards kindaThing.
think i got it.
thanks