Use the word character class. The following is equivalent to a ^[a-zA-Z0-9_]+$
:
^\w+$
Explanation:
- ^ start of string
- \w any word character (A-Z, a-z, 0-9, _).
- $ end of string
Use /[^\w]|_/g
if you don't want to match the underscore.
Use the word character class. The following is equivalent to a ^[a-zA-Z0-9_]+$
:
^\w+$
Explanation:
Use /[^\w]|_/g
if you don't want to match the underscore.