I have 4 complex regex patterns, A
, B
, C
and D
. I need to locate all the patters that are of the format of A(B AND C AND D)
where the order of B,C,D
does not matter and C
and D
are optional. Is there a way to do such a thing in regex without writing all the possible permutations of B,C,D
with or (|
) between them?
我有4个复杂的正则表达式模式,A,B,C和D.我需要找到所有格式为A(B和C和D)的模式,其中B,C,D的顺序无关紧要和C和D是可选的。有没有办法在正则表达式中做这样的事情而没有用它们之间的(?)写出B,C,D的所有可能的排列?
I'm programming this in Java, and prefer to performance-friendly. Thanks!
Edit: Changing 3 complex patters to 4 complex regex patterns.
我用Java编程,更喜欢性能友好。谢谢!编辑:将3个复杂模式更改为4个复杂的正则表达式模式。
1 个解决方案
#1
3
No. You have to write all the permutations. It is a limitation of the regular languages. Once you do it however, it will be as performance friendly as any other regular expression.
不,你必须写出所有的排列。这是常规语言的限制。但是,一旦你这样做,它将像任何其他正则表达式一样友好。
#1
3
No. You have to write all the permutations. It is a limitation of the regular languages. Once you do it however, it will be as performance friendly as any other regular expression.
不,你必须写出所有的排列。这是常规语言的限制。但是,一旦你这样做,它将像任何其他正则表达式一样友好。