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

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -