Regular Expressions: Restrict Possible Usernames issue

Regular Expressions: Restrict Possible Usernames issue

Just thought I’d point out that, unless I’m missing something here, one requirement for this challenge isn’t met by the solution/the requirement doesn’t make sense:

Usernames have to be at least two characters long. A two-letter username can only use alphabet letter characters.

A number is a character too, so this doesn’t actually mean there has to be two letter characters no matter what – contrary to the solution.

Also, I think a “two-character username” is what’s meant here – numbers are not letters.

Solution provided in the hint:

let username = “JackOfAllTrades”;
let userCheck = /^[a-z]{2,}\d*$/i;
let result = userCheck.test(username);


I agree it should say “two-character username” instead of “two-letter username”, since the last part of the sentence already says it can only use alphabet letter characters.

I am not sure the point you are making here.

For the “two-character” change, I suggest creating an issue on GitHub to discuss the reasoning about why this should be changed. I recommend referencing this thread also.


Yes maybe I’ll open an issue.

To clarify, in the solution two alphabet characters are required, but that’s only required (according to the text) when there are two total characters; this isn’t reflected in the solution. It should only have {2} if there are two characters, rather than [a-z]{2,}


Yes I agree that according to the instructions “A36” should match because:

  1. all the numbers are at the end
  2. it has lowercase letters
  3. it is at least two characters long and since it is not a two-character username it does not have to only have alphabet letters.
1 Like

That sounds good–that doesn’t actually have lowercase letters but per the instructions case shouldn’t matter (“Username letters can be lowercase and uppercase”).


Is this the place to mention that:
a) the numeric specification tool ({2, }) as proposed in the solution hasn’t been taught yet in the lessons. It appears approx three regex lessons later
b) this code passes all tests /[a-z][a-z]/i;
c) you don’t test for numbers mid-password: abc123def should not match