jay jay - 2 years ago 145
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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download