Need help on Restrict Possible Usernames

Tell us what’s happening:
Don’t know why the regular expression code not working.
I used regexr it showing correctly.
redexr link : https://regexr.com/3qiq4

Your code so far


let username = "JackOfAllTrades";
let userCheck = /[a-z]+\w+/gi; // 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) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames

Take a look at regexr again. It shows that the capital ‘J’ is not matching with this regex. Make sure to copy/paste the string to avoid typos

look I think its working properly on regexr. but in fcc challenge it can’t match “JACK” and “RegexGuru”

1


after running literal expression it can’t find.

Never mind my previous advice. I got it to work on my mobile browser. Don’t know why it was wrong on my desktop yesterday.

Try clearing your cookies. Sometimes fcc database gets corrupted

Tried clearing cookies even cache still not working.

It’s weird. It looks like they’re looking for a very specific regex, which you had so I can get it to pass with this

/[a-z]/gi

i found the solution. I remove “g” flag and it worked.

3 Likes

let userCheck = /[a-z]\w/gi;

1 Like

Do you know why this is the case? After reading this, that’s what I had to do for mine as well

I don’t know may be it is a word so “g” flag is unnecessary.