Tudor
June 16, 2020, 2:32pm
1
Hello,
First of all, sorry for bothering.
I really want to complete this challenge in this way but it seems I cannot pass 2 of the required strings and I am not sure why.
Can someone please explain me what am not taking into consideration, please?
Cheers!
Your code so far
let username = "JackOfAllTrades";
let userCheck = /^\D+[a-zA-Z]+$\d*/; // 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/83.0.4103.97 Safari/537.36 Edg/83.0.478.45
.
Challenge: Restrict Possible Usernames
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
ilenia
June 16, 2020, 3:49pm
2
these are the requirements, can you explain how each of those is satisfied by your regex?
Usernames can only use alpha-numeric characters.
The only numbers in the username have to be at the end. There can be zero or more of them at the end. Username cannot start with the number.
Username letters can be lowercase and uppercase.
Usernames have to be at least two characters long. A two-character username can only use alphabet letters as characters.
Tudor
June 16, 2020, 5:38pm
3
Hello,
Thank you for your response.
^\D - Username cannot start with one or more numbers. / part of no.2 requirement
[a-zA-Z]+ - Username letters can be one or more lowercase and uppercase. Usernames have to be at least two characters long. / requirement no.3 + part of requirement no.4 - but I think that my code does not meet the +2 character long part
$\d *- The only numbers in the username have to be at the end. There can be zero or more of them at the end. / part of requirement no.2
ilenia
June 16, 2020, 6:58pm
4
Tudor:
/^\D+[a-zA-Z]+$\d*/
so you are trying to match a number after the end of the string
careful where you put the end of string symbol