I have а sequence like:
我有а序列:
0-2014
1-2014
2-2014
...
11-2014
12-2014
0-2015
0-2016
0-2017
...
I need match any of them but with exclusion 0-2014
我需要匹配其中任何一个,但排除0-2014
Now I have only common way without exclusion:
现在我只有一个共同的方法,没有排斥:
(([0-9]{1,2})-20([0-9]{2}))
So the question: is it possible to exclude 0-2014
from matching? And How?
所以问题是:是否有可能将0-2014排除在匹配之外?以及如何?
2 个解决方案
#1
2
You can use a negative look ahead :
你可以用消极的展望:
((?!0-2014)([0-9]{1,2})-20([0-9]{2}))
演示
Also if you don't need inner groups you can use non capture-grouping for them :
另外,如果你不需要内部团队,你可以使用非分组的方法:
((?!0-2014)(?:[0-9]{1,2})-20(?:[0-9]{2}))
#1
2
You can use a negative look ahead :
你可以用消极的展望:
((?!0-2014)([0-9]{1,2})-20([0-9]{2}))
演示
Also if you don't need inner groups you can use non capture-grouping for them :
另外,如果你不需要内部团队,你可以使用非分组的方法:
((?!0-2014)(?:[0-9]{1,2})-20(?:[0-9]{2}))