* fix: restructure certifications guide articles * fix: added 3 dashes line before prob expl * fix: added 3 dashes line before hints * fix: added 3 dashes line before solutions
595 B
595 B
title
title |
---|
Restrict Possible Usernames |
Restrict Possible Usernames
Solutions
Solution 1 (Click to Show/Hide)
let username = "JackOfAllTrades";
const userCheck = /^[a-z]([0-9]{2,}|[a-z]+\d*)$/i;
let result = userCheck.test(username);
Code Explanation
^
- start of input[a-z]
- first character is a letter[0-9]{2,0}
- ends with two or more numbers|
- or[a-z]+
- has one or more letters next\d*
- and ends with zero or more numbers$
- end of inputi
- ignore case of input