To reuse a pattern, you could use (?n)
where n
is the number of the group to repeat. For example, your actual pattern :
(PAT),(PAT), ... ,(PAT)
can be replaced by:
(PAT),(?1), ... ,(?1)
(?1)
is the same pattern as (PAT)
whatever PAT
is.
You may have multiple patterns:
(PAT1),(PAT2),(PAT1),(PAT2),(PAT1),(PAT2),(PAT1),(PAT2)
may be reduced to:
(PAT1),(PAT2),(?1),(?2),(?1),(?2),(?1),(?2)
or:
((PAT1),(PAT2)),(?1),(?1),(?1)
or:
((PAT1),(PAT2)),(?1){3}