jay jay - 10 months ago 74
Javascript Question

Validate nickname with regex

I neet to validate a nick name without

and it can't start with numbers

thi is my solution but the

(^[^0-9])([\w a-z A-Z 0-9][^@#])


andrea //true
0andrea // false

// these are true but I need them to be false

and@rea // true
and#rea // true


your regex:

^(^[^0-9])([\w a-z A-Z 0-9][^@#])$


  1. dont start with a number.start with any thing other than numbers.

  2. two letter upper/lower case or digit or underscore followed by any of ^@#

SO according to your regex, any three letter word will be matched.

use this:


this will work for usernames not conatining any special chars.

If you specifically just not want @ and #. use this :


demo here : https://regex101.com/r/gV9eO0/1