开发者

Regex to match alphanumeric character and ampersand(&)

开发者 https://www.devze.com 2023-03-10 18:05 出处:网络
I need regex to search string for alphanumeric, (, ), -, ., / and ampersand(&). Right now i m using this regex in client side validation

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

精彩评论

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

关注公众号