Restrict Possible username challenge

let username = "JackOfAllTrades";
let userCheck = /^[a-z]*\d/ig; // Change this line
let result = userCheck.test(username);

Can someone please tell me why this is not targeting the alphabets ?

You are looking for a specific set, in this case all lowercase letters. Make sure you are including uppercase letters in your bracket.

The asterisk * means zero or more. You want something that will not start from zero

i added the ignore case flag at the end , so it targets both upper and lower cases

1 Like

@hbar1st it says it is valid to have only letters in a username so, adding the astrix makes it possible for the username to be just alphabets or both alphabet and numbers. I tried removing the * still not working .

If you remove the star without adding anything then you will require a single letter only. What you want is something that matches more than one