Solution to the Restrict Possible Usernames does not make sense to me

I thought I understood these charagter regex thing but after seeing the solution (/[1] [a-z]+\d*$|[2] \d\d+$/i;), I don’t.

The exercise literally states “A two-character username can only use alphabet letters as characters.” so what is \d* doing in the expression?? If I am not wrong, the * means 0 or more numbers NOT 0 numbers. The code explanation just confuses me more about when now to use + and *.

Your code so far

let username = "JackOfAllTrades";
let userCheck = /change/; // Change this line
let result = userCheck.test(username);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36

Challenge: Restrict Possible Usernames

Link to the challenge:


  1. a-z ↩︎

  2. a-z ↩︎

\d* means indeed 0 or more numbers. If there’s 0 numbers, then username has only letters and can have only two characters. Otherwise it’s not two letter username.

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