如何编写正则表达式来验证逗号分隔的未知大小的整数列表?
308091,1213,13414,12132,14431,14343,234,4334,2,34234,2344,32424
应该匹配,最好是如果我也可以验证没有尾随逗号,那将是伟大的...不知道我会如何写这个或者它是否可能...字母应该失败,除了数字和逗号之外的任何符号都应该失败,任意数量的整数应该可以从一个“12345”或两个“12345,12345”一直到无穷大“12345,98765,...”
祝你好运
308091,1213,13414,12132,14431,14343,234,4334,2,34234,2344,32424
should match, preferably if I could verify also that there was NO trailing comma that would be grand... not sure how I would write this or if it would even be possible... letters should fail, any symbols besides numbers and commas should fail, any number of integers should be possible from one '12345' or two '12345,12345' and on to infinity '12345,98765,...'
good luck
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只想要数字(因此 0123 不起作用),那么您可以使用以下模式:
If you want only numbers (so 0123 wouldn't work) then you could use this pattern:
您还可以使用:
You can also use: