验证场结构的正则表达
我想在Linux中实现一个正则表达式,该表达式使用GREP允许我验证一个字段包含15个数值,并且占据第五位置的值(从左开始)是5或6。
我已经达到了点但是,确定其最多包含15个值的要求,我找不到占据第五位置的一个值是5或6。这是:
grep -E "^[0-9]{1,15}"
有什么想法吗?
I would like to implement a regular expression in linux that using grep allows me to verify that a field contains 15 numerical values and that the value occupying the fifth position (starting from left) is either a 5 or a 6.
I have reached the point of defining the requirement that it contains a maximum of 15 values, however, I can not get that the one that occupies the fifth position is a 5 or 6. It would be:
grep -E "^[0-9]{1,15}"
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于正好的15个数字,5个位置为5或6:
^
String的启动[0-9] {4}
匹配4位数字[56]
匹配5
或6
[0-9] {10}
匹配10位数字$
结束of stringTo match at least the first 5 characters followed by 0-10 digits after it, and allow a partial match like matching
123462222233333
in12346222223333344444
For exactly 15 numbers, and the 5 position is either 5 or 6:
^
Start of string[0-9]{4}
Match 4 digits[56]
Match either5
or6
[0-9]{10}
Match 10 digits$
End of stringTo match at least the first 5 characters followed by 0-10 digits after it, and allow a partial match like matching
123462222233333
in12346222223333344444