开发者

In javascript how can i use regex to validate comma with other characters

开发者 https://www.devze.com 2023-03-17 16:38 出处:网络
In javascript how can开发者_如何转开发 i use regex to validate comma with characters. I\'m doing this

In javascript how can开发者_如何转开发 i use regex to validate comma with characters. I'm doing this

return /^[a-zA-Z_-]+$/i.test(value);

which is working perfect but I want to add comma like this

return /^[a-zA-Z_-,]+$/i.test(value);

which is not working.


Inside a character class, - is a special character (indicating a range between the preceding and the following character) unless it is the first or last character in the class:

return /^[a-zA-Z_,-]+$/i.test(value);
0

精彩评论

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

关注公众号