Restrict Possible Usernames Question

Tell us what’s happening:

I attempted this using and it worked, but, when I test it here, it says that JACK and RegexGuru don’t work.

Your code so far

let username = "JackOfAllTrades";
let userCheck = /^[A-Za-z][A-Za-z]+\d*/gi; // 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/67.0.3396.87 Safari/537.36.

Link to the challenge:

You are practically there. All you have to do is remove the flags from your regex.

1 Like

And here is why:


Interesting, thanks!!

regex101 by default uses the php regex engine, while FCC uses browser(js) regex engine. Not sure even the js option in regex101 uses local(browser) js engine. you may try also that uses local browser I think.

First, this [A-Za-z][A-Za-z]+ could be in something smaller(more logical) as [A-Za-z]{2,}
Also as you specified /i as case insensitive, so A-Z also is redundant, so it could be[a-z]{2,}

Just as @Tomvbe and @BenGitter stated(which I didn’t know too, thanks) seems like the g flag is the tip.

Keep goin on great work, happy programming


Thank you, I will try that website!