Regular Expressions Lesson 29

So I am not really sure what does the lookhead at the first of the string do? since it checks if something is followed by like x(?=y)

(\w{4,})(?=\d{2})

FCC Solution /(?=\w{6})(?=\w*\d{2})/


let sampleWord = "astronaut";
let pwRegex = /(\w{4,})(?=\d{2})/; // Change this line
let result = sampleWord.match(pwRegex);

Your browser information:

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

Challenge: Positive and Negative Lookahead

Link to the challenge:

it search \w{4,} (4 or more character of a word) that followed by \d{2} (two digit number)
ex. RegEx12 it will match ‘RegEx’ without including 12

Yes that is my solution. I was inquiring about FCC solution
/(?=\w{6})(?=\w*\d{2})/

the first lookhead make sure that the string consist of greater than 5 or 6 character

so it says a string with 6 character followed by zero or more characters and 2 digits number? why does this one match Pa16ssrd? it’s not 6 character string it’s 8