Regular Expressions - Restrict Possible Usernames

Tell us what’s happening:
Describe your issue in detail here.
I just recreate the soulation 1 by using shorthand character classes
but it didn’t match with some of those rules.
why is this happening
Your code so far

let username = "JackOfAllTrades";
let userCheck = /^\w\w+\d*$|^\w\d\d+$/i; // Change this line
let result = userCheck.test(username);

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

Challenge: Regular Expressions - Restrict Possible Usernames

Link to the challenge:

\w and \d both matches numbers so one of the failure cases is that your pattern is matching 007
(which is not a valid username)

so you mean that ** \w**matches word as well as digits, isn’t it?

You can use this cheat sheet to answer your question

Thanks for your resource

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