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 = /[1]{2,}\d*$/i;
let result = userCheck.test(username);


  1. a-z ↩︎

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,}

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

1 Like