Learn Regular Expressions: Restrict Possible User Names

Tell us what’s happening:
I did not fully understand what was wanted of me in this lesson. So I went to Hint and wrote in the answer supplied. The code was returned as entirely incorrect. I need an explanation of the lesson and help with my code. Please help!

Your code so far


let username = "JackOfAllTrades";
let userCheck = /^[a-z]([0-9]{2,}+|[a-z]+\d*)$/i;      // Change this line
let result = userCheck.test(username);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:74.0) Gecko/20100101 Firefox/74.0.

Challenge: Restrict Possible Usernames

Link to the challenge:

/^[a-z]([0-9]{2,}+|[a-z]+\d*)$/i;
This regex you provided appears to have an error. Looking at the description of the code in the solution page might help you determine where the error is.

I found out what I did wrong! There should not be a + sign in this code by the {2,}. It was my fault. Oops! Live and learn. :upside_down_face: Thank you for helping me to think. :+1:

1 Like

I am glad I could help!

1 Like