508 B
508 B
title
| title |
|---|
| Restrict Possible Usernames |
Restrict Possible Usernames
Solution:
let username = "JackOfAllTrades";
const userCheck = /^[a-z]([0-9]{2,}|[a-z]+\d*)$/i;
let result = userCheck.test(username);
Explain:
^- 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