开发者

Regex to match alphanumeric character and ampersand(&)

I need regex to search string for alphanumeric, (, ), -, ., / and ampersand(&).

Right now i m using this regex in client side validation

 [^A-Za-z0-9.)(/-\&]

EDIT:

I want to s开发者_StackOverflowearch my string for special characters VAL.search(/[^A-Za-z0-9.)(/-\&]+/g)==-1


Escape the backslash, put the dash at the end of the character class.

[^A-Za-z0-9.)(/\\&-]

Not sure why you included ^, as this negates the character class.


Try this:

VAL.search(/[^a-zA-Z0-9.()/&-]/g) == -1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜