Regular Expressions - Restrict Possible Usernames

let username = “JackOfAllTrades”;
let userCheck = /[1]{2,}\d*$|[2]{1,}\d\d+$/i; // Change this line
let result = userCheck.test(username);

the challenge can also be solved in this way too, if i am not wrong
Explanation:
^- at the start
[a-z]{2,}- 2 or more alphabet
\d*$- 0 or more number/s at the end
or-
^- at the start
[a-z]{1,}- 1 or more letter/s
\d\d+$ 2 or more numbers at the end
i- so that it match both uppercase and lowercase


  1. a-z ↩︎

  2. a-z ↩︎

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