Restrict-possible-usernames

Tell us what’s happening:
The following code is passing all of the tests for this challenge. But the requirement statements are not fully tested by the current testcases.

There should be more testcases that cover having digits in the middle of the alphabetic characters, and numbers at the beginning of the username to cover cases where the alphabetic characters are not anchored to the beginning of the string.

I think that the correct expression to cover the requirements would be /^[a-z]{2,}\d*$/i with other variations such as /[a-zA-Z]{2,}[0-9]*$/.

Thanks for checking this, I’ll be interested to see what other’s thoughts are on this.

Your code so far



let username = "JackOfAllTrades";
let userCheck = /^[a-z]{2,}/i; // 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/64.0.3282.186 Safari/537.36 OPR/51.0.2830.55.

Link to the challenge:

1 Like

You can write a GitHub Issue suggesting better test cases.

I’m struggling with this one too. Your regex seems to validate all the cases here.
However “JACK” and “RegexGuru” are not validating when running the test.

This one worked for me:
/^[a-z]{2,}/i