Question about --> Regular Expressions: Positive and Negative Lookahead

Regular Expressions: Positive and Negative Lookahead

assignment: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead

5 characters long and have two consecutive digits. 78777 meets these two requirements.

/(?=\w{3,})(?=\D\d{2,})/ - This solution is a valid solution to this assignment.

So result should equal true. But that is not the case. It indicates here that it is false.

What is happening?

I think this is the right solution --> /(?=\w{3,})(?=\D*\d{2,})/

Kind regards, Fabian

Love this community :slight_smile:

It’s asking you for something that is at least 5 characters long, yours is checking for something that is at least 3 characters long.

Perfect i understand. Thank you.

1 Like

Also true. How easy it is to make mistakes…

Oops, reading fail on my part as well, sorry!