Regular Expressions: Restrict Possible Usernames Problem

Regular Expressions: Restrict Possible Usernames Problem
0

#1
let username = "JackOfAllTrades";
let userCheck = /^[a-z]{2,}\d*$/i;
let result = userCheck.test(username);

Hey guys, I have made the challenge but I have one thing in my mind that I’m wondering.

let userCheck = /^[a-z]{2,}\d*$/i;

In here why we used \d* not the \d ? What is the reason of * character?


#2

It matches 0 or more of the preceding token. In your case, 0 or more digits.


#3

There is a perfect tool to handle regExps


You see in real time the effects, with due comments.
You can even write tests.
Definitely to recommand for beginners as for ninjas