Regular Expressions: Positive and Negative Lookahead


For the following question:
" Use lookaheads in the pwRegex to match passwords that are greater than 5 characters long, and have two consecutive digits."

Why did my code /(?=\w{6,})(?=\d{2})/ not work.

But /(?=\w{6,})(?=\w*\d{2})/ does work…

I don’t understand why the \w* makes a difference???


I keep linking to my old explanation, but I’m too tired to explain it again, so you get the link :slight_smile:

I’m sorry! I did make an attempt to look for a similar answer.

Thank you for this!

No need to apologize. It’s not always easy to search and find what you are looking for.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.