[英]Range of digits in Regex
I have got this format of data 我有这种数据格式
*0179*1*A*500000000,M-00,R-12113
* 0179 * 1 * A * 5亿,M-00,R-12113
Regex is tested here http://regexstorm.net/tester 正则表达式在这里经过测试http://regexstorm.net/tester
\*\d{4}\*\d{1}\*[ABCEFGHJKLMPRV]{1}(\*)\d+\,M-\d{2},R-\d{5}
This part 12113
should be 1-5 in length. 这部分
12113
长度应为1-5。
This part 500000000
shoul dbe 1-13 digits in length. 这
500000000
部分的长度应为1-13位数字。
So I need to define a regex with a variable length for those parts. 因此,我需要为这些零件定义一个长度可变的正则表达式。 Any clue?
有什么线索吗?
Just use the appropiate quantifiers 只需使用适当的量词
\*\d{4}\*\d\*[ABCEFGHJKLMPRV](\*)\d{1,13}\,M-\d{2},R-\d{1,5}
{x,y} means atleast x and max y times. {x,y}表示至少x和最大y次。
For some better English explanation, just check any regex reference . 有关更好的英语解释,只需检查任何正则表达式参考 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.