验证复杂字符串输入(固定长度模式)
验证此类输入的最佳方法是什么:
1234,4589,7889
仅允许的数字。每个数字必须包含 4 位数字。它们由 ,
分隔。可以有一个,也可以有多个。最后一项没有分隔符。
What is the best way to validate this type of input:
1234,4589,7889
Only allowed numbers. Each number must contain 4 digits. They are separated by ,
. There can be one or many. Last item does not have a separator.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
\d{4}
\d{4},\d{4}
(?:\d{4},)+
\d{4}(?:,\d{4})*
^\d{4}(?:,\ d{4})*$
以确保模式覆盖字符串的开头和结尾。\d{4}
\d{4},\d{4}
(?:\d{4},)+
\d{4}(?:,\d{4})*
^\d{4}(?:,\d{4})*$
to make sure the pattern cover the start and the end of the string.