Positive and Negative Lookahead

Positive and Negative Lookahead

The solution seems to be off a bit. I am just starting to learn regex but, I think that

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

is more accurate with the directions. The only difference is the commas after the digits which, I think, allows for more than just 6 letters and 2 numbers.

I don’t think you need the commas here because you don’t care if there are more than 6 alphanumeric characters, only that there are at least 6. Same for 2 digits.

Look at the strings that are being tested. The strings astr1on11aut and abc123 pass even if you don’t use commas.

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