Regular Expressions - Restrict Possible Usernames

Tell us what’s happening:
Describe your issue in detail here.
I don’t even know what is going on and how this work , found the answer on youtube. Could some one explaint to me the code. I only know the first [1] which is work for the first string. The rest is none on my brain.

Your code so far

let username = "JackOfAllTrades";
const userCheck = /^[a-z]+([a-z]\d*|\d\d+)$/gi;
let result = userCheck.test(username);


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0

Challenge: Regular Expressions - Restrict Possible Usernames

Link to the challenge:

  1. a-z ↩︎

You can try to decipher it, split it, and deal with each part:


second part is still little bit heavy
split it into 2


don’t forget that it was separated with pipe | and had $ at the end

Aslo, g and i flags are important.

Now you have bunch of small things to figure out instead of one big.

For each part you don’t understand, do research. If it won’t help, ask specific questions about it.

I could decipher whole thing for you right away, but I don’t think it would be the best help.

1 Like

what this \d* stand for i don’t understand it .

and this one too how does it relate to all the test case i don’t understand.

the $ mark behind () what does it use case

I do understand this one from w3school explanation and the video on youtube have me a bit.

\d - its numeric character
* - that means ‘0 or more times’
challenge step:

It means
1 numeric character followed by one or more numeric characters
Challenge step about the +

About the $, step has use case I believe:

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