Regular Expressions: Restrict Possible Usernames -- Feedback on my solution?

Hello all, newbie here.

After hours of research and trying different things I finally came up with an acceptable solution.

My progress really sped up once I saw someone suggesting this tool – https://www.regexpal.com/

For anyone struggling I really suggest it!

Does anyone have any feedback on my code? Any suggestions on how it could improve or anything that seems redundant?

let userCheck = /^[a-zA-Z]+([a-zA-Z]|\d{2,}?)$/i; // Change this line

Thanks! :relieved:

The link looks cool
the code 2

let userCheck = /^[a-zA-Z]+([a-zA-Z]|\d{2,}?)$/i; // Change this line

but what is it suppose to do?

Oops ---- I didn’t link properly to the problem.

This regex will fail to validate usernames ending with just a single digit, like, mikemaer2. The ? doesn’t serve any purpose too – since we’re using the $ anchor, the digits match can never be lazy.

Mike, I’m sure you’ve moved much further ahead on FCC; this is just for any newbies checking the forum for different solutions to this exercise.


  1. a-zA-Z ↩︎