Checking usernames with regex

Correct. You could replace ^[a-z][a-z]+ with ^[a-z]{2,}.

This is caused by a “quirk” with how the tests interact with the global flag. If you want to know all the gruesome details you can find them in this thread.

You don’t need the global flag here because you aren’t searching for multiple matches in a string. Each string being tested contains only one username and you are doing the pattern matching on the entire string, not trying to find sub-patterns in the username.

Yes, technically this challenge should pass with the global flag but adding the global flag is not needed in this case, so I would argue that the challenge is teaching you not to add things that aren’t needed :slight_smile:


  1. a-z ↩︎

1 Like