Restrict possible username ... stuck here , anyone got time to help?

Tell us what’s happening:

can anyone please tell how i’m failing to make sure that :

  • the username don’t start with numbers and in case there are numbers , they stay at the end
  • in case the username is only made of two digits that those two are letters

Your code so far


let username = "JackOfAllTrades";
let userCheck = /^\w+.\d*$/; // Change this line
let result = userCheck.test(username);

these are the requirements  that my current code can't pass: 
 Your regex should not match 007
 Your regex should not match A1
 Your regex should not match BadUs3rnam3
 Your regex should not match c57bT3

**Your browser information:**

User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36</code>.

**Challenge:** Restrict Possible Usernames

**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames

i removed the \w and replaced it with [a-zA-Z]
here’s my current code , i was confused as to how to use it

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

the only error message that i’m receiving is :

Your regex should not match A1

Your current pattern is “At least one letter followed by zero or more numbers”. That’s why “A1” is matching. You need to modify your pattern so that it will not match a string that is one letter followed by one number.
(Your current pattern also allows usernames to be a single letter.)

this was my solution to the challenge

let username = "JackOfAllTrades";
let userCheck = /^(\D)(\d{2,}|[a-zA-Z]+\d*)$/i; // Change this line
let result = userCheck.test(username);

Good job finding a solution! Happy coding :smiley: