javascript - Regex Expression to allow underscore,hyphen and '&' symbol -
regex expression allow alphanumeric , special characters '-','_','&'
only. have tried regex not working !
var testexp=/^[a-za-z0-9-_&]+$/;
you need put -
@ end (or @ beginning) of class if want considered real char:
/^[a-za-z0-9_&-]+$/
you use shortcut \w
, same [a-za-z0-9_]
. thus:
/^[\w&-]+$/
Comments
Post a Comment