Restrict Possible Usernames Challenge

Restrict Possible Usernames Challenge
0.0 0


Can anybody tell me what’s wrong with my Regex? It passes all tests but one: “Your regex should not match 007”

let username = "JackOfAllTrades";
let userCheck = /[\w]{2}\d*$/i; 
let result = userCheck.test(username);


[\w]{2} means exactly 2 of any word character (ie, a-z, A-Z, 0-9)

\d*$ means 0 or more of any digit characters at the end of the string

So putting those together, your RegEx will match any strings, as long as they have exactly 2 word characters at the beginning, and 0 or more digits at the end.

Here are a few pieces that might help you build your RegEx:
[a-z] means any character from a to z
\D means any non-digit character
{2,} means 2 or more
^ means at the start of the string


\w includes letter and digits as well. so for [\w]{2} the 00 matches. also \d means digit for 7, so 007 matches.

Please share the case-study link also so we can help better.


Thanks a lot for your help! It worked! Cheers! <3


Thanks for your help!!!