Problem with the Hint 2 (Positive and Negative Lookahead)


The problem is related to the Hint 2 (freeCodeCamp Challenge Guide: Positive and Negative Lookahead) of the challenge " Positive and Negative Lookahead" (

The Hint 2 finishes with “Remember to specify the exact amount of numbers you want to appear at the end of the string.”

But the checklist in the challenge says that “Your regex should match the string astr1on11aut”.

I’m novice, so I might be wrong, but I think that it should be like “Remember to specify the exact amount of numbers you want to appear consecutively on the string.”

Anyway, if I’m wrong, I’m sorry and, if it’s possible, explain me why it is right.

Kind regards!

1 Like

Hi Marcos,

Remember this paragraph from the first lesson or challenge in the Regular Expressions course (

I quote it below:

" If you want to find the word the in the string The dog chased the cat , you could use the following regular expression: /the/ . Notice that quote marks are not required within the regular expression. "

With that understanding, I think the statement you referenced from Hint 2 is talking about the string that you put in myRegex.

So this is what I think it meant to communicate : Remember to specify the exact amount of numbers you want to appear at the end of the regex string.

I think thus that your concern is legitimate.

Best regards.

1 Like

That makes more sense now!
Thank you so much!! =D

1 Like

Welcome Marcos. I’m glad.

1 Like

(?=\w*\d{2,}) hello :wave:
dont understand why do we need \w at first wright
and why this combination works, but not togeather

//(?=\d{2})/ // filter for at list 2 numbers

//(?=\w{6})/   // filter for more then 6 symbols

I am novice too and maybe could be wrong but as far as I understand when it specifes that you have to find exact matches, like in this case, 2 consecutive digits, it means that you have exclude everything else and just look for two consecutive digits. Correct me someone if I’m wrong, please.

the two lookaheads look from same position, if you don’t write \w* then the second lookahead is imposing that the numbers have to be at the start of the 6 characters matched by the other lookahead