I was able to get a match using:
(?![^(]*\))\s*(code (?:civil|pénal|de procédure civile|de procédure pénale))\s*
To break this down:
(?![^(]*\))
This is a negative lookahead, it stipulates that we shouldn't capture matches where the text begins with a
(
and ends with a
)
. I suppose important to note with this is that it
will match if the term is within parenthesis without a closing symbol.
\s*
This checks for zero or more spaces. By placing this before the
code
part we're saying that we don't want to capture the spaces around the words.
(code (?:civil|pénal|de procédure civile|de procédure pénale))
This captures the whole text as part of a match group. You'd need to adjust your code to pick the first group matched rather than the whole text. The
(?: ... )
bit just means "we want to match this but we don't want it to be a separate group"
Someone else might have a better way of capturing this but I tested this at
regex101[^] and it seemed to work!