![](/img/trans.png)
[英]remove comma seperated string and replace it in javascript regex
[英]Regex to validate comma seperated string in Javascript
我想使用正则表达式验证逗号分隔的字符串。
我的样本输入
hello,hi,hey,there,where - Valid
hello hi,hey there,hey,hi - InValid(space between word should invalid)
hello,hi,hey,there,where, - Invalid - Comma at end
,hello,hi,hey,there,where - Invalid - Comma at beginning
hello,hi,,hey,there,where - Invalid - No value between 2,3 comma
我尝试使用这个正则表达式 [0-9a-zA-Z]+(,[0-9a-zA-Z]+)* 但它现在适用于所有情况。
就像这样: ^[0-9a-zA-Z]+(,[0-9a-zA-Z]+)*$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.