Restrict Possible Usernames-error

Tell us what’s happening:
the “regex” i have mentioned is perfectly working with all the expressions given , when i am using in RegExr, but when i run it here it does not match for JACK, plz help.

Your code so far

let username = "JackOfAllTrades";
let userCheck = /[a-z]..+|[a-z][a-z]|[a-z].+\d$/gii; // 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/69.0.3497.100 Safari/537.36.

Link to the challenge:

Thats because in your regex you havent included the matching for an Uppercase Letter since J in JackOfAllTrades is uppercase.
It should be [a-zA-Z]

Yes he has, that’s what the i flag is for, but as it turns out, that’s the issue:

@adarshk010 the test won’t work with flags, you need to explicitly use [a-zA-Z]. This is failing of the test, not of the code. That being said:

  • You have an extra i
  • The code doesn’t match the description even though it will pass the tests - because . matches anything, [a-z].+\d$ never gets touched, and the tests will pass wherever the numbers appear in the string, not just at the end (The only numbers in the username have to be at the end. There can be zero or more of them at the end.)