Regular Expressions - Restrict Possible Usernames

Tell us what’s happening:
I solve everything but only one give me a lot of problems :frowning:
the last one J%4 should not be matched

Your code so far (with more solutions correct, only one wrong)

let username = "JackOfAllTrades";
let userCheck = /(^\D{2,})(\d*$)|(^\D)(\d{2,}$)/; // Change this line
let result = userCheck.test(username);

Possible mine solution that isn’t right

I thinked of something like ^\D[^\W]{2,}, which in my mind is like "at the start don’t match a number for more than 2 times but check also that character isn’t a symbol.

/(^\D[^\W]{2,})(\d*$)|(^\D[^\W])(\d{2,}$)/ but it totally messed up also all the other correct ones, so for me I need a modified version of this (^\D{2,})(\d*$)|(^\D)(\d{2,}$) which include the functionality of excluding symbols.

Description of what I understand, prove me wrong if something isn’t right

^ = at the start
\D = any character that isn’t a number, so is a alphabet only
[^] = not of a set of characters
\W = not a letter, so not a symbol.
{2,} = 2 or more characters

what should be matched and what not?
:white_check_mark: Jo
:white_check_mark: Z97
:white_check_mark: AB1
:white_check_mark: JACK
:white_check_mark: Oceans11
:white_check_mark: RegexGuru

:x: J
:x: 9
:x: A1
:x: 007
:x: c57bT3
:x: BadUs3rnam3
:x: J%4 ← here my problem

Your browser information:

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

Challenge: Regular Expressions - Restrict Possible Usernames

Link to the challenge:

I charged now the \D to [a-z]… now works great :slight_smile:

I am still thinking of why \D[^\W] doesn’t want to work? (just my curiosity)

Code that I have now

/(^[a-z]{2,})(\d*$)|(^[a-z])(\d{2,}$)/i

remember /i because so you need to write also [A-Z] you get uppercase and lowercase characters