"Regular Expressions - Restrict Possible Usernames" Possible Fault in Checklist

Tell us what’s happening:
Describe your issue in detail here.
Hello, can someone check this for me?
I’m doing this practice and here are the rules to check using regex:

1. Usernames can only use alpha-numeric characters.

2. The only numbers in the username have to be at the end. There can be zero or more of them at the end. Username cannot start with the number.

3. Username letters can be lowercase and uppercase.

4. Usernames have to be at least two characters long. A two-character username can only use alphabet letters as characters.

So I have made my code as shown below:
Your code so far

let username = "Z97";
let userCheck = /^[a-z][a-z]\D*\d*$/i; // Change this line
let result = userCheck.test(username);
let check = username.match(userCheck);

But then in the checklist of the practice, there is a check that requires “Z97” to be passed, which goes against Rule No.4. My code was disqualified because of it.

And then there is a check that “A1” is not to be passed, which is correct regarding Rule No.4. If I turn the 2nd character check to be [/w] then this check rejects my code (as it should do).

I can bypass this by fixing the 2nd character check to be [a-z9] but I think it’s a typo. Can someone check it or is it intended?
If it’s a typo can someone fix it, please?

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0

Challenge: Regular Expressions - Restrict Possible Usernames

Link to the challenge:

No, it is valid. It is at least two characters long.

No, it is not a valid username, as it is two characters long but doesn’t consist only of letters.

I see, thank you very much. I guess I was confused when trying to combine all the rules.
Should I use if to separate the “at least 2 characters long” cases or there is a way to combine it into a single regex?

I used this lesson to handle that part

I see! Thank you very much!

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