开发者

Regex for validating a string with pre-specified special characters

开发者 https://www.devze.com 2022-12-24 14:01 出处:网络
I am looking for a regex to validate a string. I want to allow numbers, alpha characters, spaces and any of the following characters in any order:

I am looking for a regex to validate a string. I want to allow numbers, alpha characters, spaces and any of the following characters in any order:

+ - ( ) ,

I would be grateful if someo开发者_开发技巧ne could help. thanks


Like this:

/^[a-zA-Z0-9 +(),-]+$/

EDIT: Now accepts spaces.


The correct regex was:

^[a-zA-Z0-9+\\s(),-]+$

many thanks to Slaks who almost responded with the correct one except not accomodating the whitespaces


/^[a-zA-Z0-9+(), -]+$/
0

精彩评论

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