Tell us what’s happening:
I solve everything but only one give me a lot of problems
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?
Jo
Z97
AB1
JACK
Oceans11
RegexGuru
J
9
A1
007
c57bT3
BadUs3rnam3
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: