Regex for matching groups in no particular order

I have 4 complex regex patterns, A , B , C and D I need to find all patterns that have format 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 a regular expression without writing down all possible permutations of B,C,D c or ( | ) between them?

I program this in Java and prefer friendliness. Thanks!

Edit: Change 3 complex patterns to 4 complex regular expression patterns.

+4
source share
1 answer

Not. You must write all permutations. This is a limitation of common languages. However, as soon as you do this, it will be as convenient as any other regular expression.

+3
source

Source: https://habr.com/ru/post/1397000/


All Articles