I need to match specific words in a text, but not if they're inside parenthesis (with or without other words within).
For example, in the text
La première édition du code civil français est l'aboutissement d'une double réflexion menée afin d'améliorer les échanges juridiques ... (édition du code civil français) est ...
I need to match the first "code civil" words, but not the last ones (inside parenthesis).
I'm using the following regular expression
/[^(]code (civil|pénal|de procédure civile|de procédure pénale)[^)]/g
The issue is that - referring to the example - it also matches the spaces before and after "code civil" (i.e.: " code civil ").
How can I remove those spaces?
Thanks in advance.
For example, in the text
La première édition du code civil français est l'aboutissement d'une double réflexion menée afin d'améliorer les échanges juridiques ... (édition du code civil français) est ...
I need to match the first "code civil" words, but not the last ones (inside parenthesis).
I'm using the following regular expression
/[^(]code (civil|pénal|de procédure civile|de procédure pénale)[^)]/g
The issue is that - referring to the example - it also matches the spaces before and after "code civil" (i.e.: " code civil ").
How can I remove those spaces?
Thanks in advance.