Restrict Possible Usernames with shortcut

Tell us what’s happening:
I’ve been trying so hard to complete this task and it kept showcasing errors. The hint isn’t in correlation with the shortcut style of regrex required. Will appreciate help from pros here. Thanks

Your code so far


let username = "JackOfAllTrades";
let userCheck = /\D\w+\d*?/ig; // 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/99.0.4844.84 Safari/537.36

Challenge: Restrict Possible Usernames

Link to the challenge:

Can you walk us through what you think that regex is doing?

I hate regex… except that it is incredibly powerful and it often saves the day. But I can never remember it all. I often go to sites like regex 101 to test them out.

Read the specs closely. The way I read them, there are really two possibilities … Hint: You may need the “alternate” (OR) character. It might be worthwhile to write those out, what the “rules” are, visually and then translate them to regex.

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