my code doesnt pass the following:
Your regex should match JACK
Your regex should match RegexGuru
can somebody help?
Your code so far
let username = "JackOfAllTrades";
let userCheck = /[A-Za-z][0-9$]/g; // 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/72.0.3626.119 Safari/537.36.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames
Gunjan
March 2, 2019, 5:22pm
2
let userCheck = /^[a-z]{2,}\d*$/i;
Look here
The only numbers in the username have to be at the end. \d$ There can be zero or more of them at the end. *
/\d*$/;
Username letters can be lowercase and uppercase. i
/\d*$/i;
Usernames have to be at least two characters long. {2,} A two-letter username can only use alphabet letter characters. ^[a-z]
/^[a-z]{2,}\d*$/i;
1 Like
ILM
March 2, 2019, 6:03pm
3
Your regex will match a word that ends with a letter and a number, you need to add quantity specifiers to both. Also you will need also to add the match for the beginning of the string
Quantity specifier because you need at least 2 letters, and then you can 0 or more numbers at the end of the word
1 Like