Regular Expressions - Restrict Possible Usernames

My code is matching passwords that have numbers in the body of the password as well as at the end and I’m not sure why! Please could someone explain?

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.47

Challenge: Regular Expressions - Restrict Possible Usernames

Link to the challenge:

I think it’s trying to match to passwords that have 0 or more digits positioned at the end and are preceded by 1 or more alpha characters

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