Regex error : Restrict possible usernames

Tell us what’s happening:
The freecodecamp’s compiler is matching the following regex : /[a-zA-Z][a-zA-Z]|[a-zA-Z]+[0-9][0-9]+|[a-zA-Z][a-zA-Z]+[0-9]+/

with string : “c57bT3”

Edit : My question is the compiler shouldnt match the above regex with the string above.( I tried matching this regex with the string on https://regexr.com and it didn’t match there)

Your code so far


let username = "JackOfAllTrades";
let userCheck = /[a-zA-Z][a-zA-Z]|[a-zA-Z]+[0-9][0-9]+|[a-zA-Z][a-zA-Z]+[0-9]+/; // 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/66.0.3359.170 Safari/537.36.

Challenge: Restrict Possible Usernames

Link to the challenge:

do you have a question?

Welcome, crispbacon.

The regex provided should match because it is testing for:

  • [a-zA-Z][a-zA-Z]+[0-9]+

This matches: c57

Also, I see regexr.com matches:

Hope this clarifies

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