我想写一个正则表达式来匹配一个页面范围,但更复杂!
我需要匹配以下字符串:
1-20 : from No.1 page to No.20,
1-20x2: from No.1 to No.20 and step is 2, so it'll print 10 pages
1-20a2: from No.1 to No.20, every 2 page printed to 1 paper
1-20x2a2:
1-20a2x3:
1,3-20a2x3,
1-20a2x3,30-35x2
1-20x3a2,30-25a2
我写了一个正则表达式:
^([0-9]*|[0-9]*-[1-9][0-9]*(x[1-9][0-9]*)?(a[1-9][0-9]*)?)(,([0-9]*|[0-9]*-[1-9][0-9]*(x[1-9][0-9]*)?(a[1-9][0-9]*)?))*$
几乎可以匹配所有情况,但是“x”和“a”的顺序不能改变,
所以请帮我解决它!谢谢你 !