I am learning REGEX and I have the following string:
minchiase (se), minchiase se
My goal is to remove all the se
and (se)
from the string except the ones that are inside of a word. The final result should be:
minchiase , minchiase
So far I tried this \b(se)
but I am only able to identify the last se
but not the one between the parenthesis.
Would you be able to suggest a smart and elegant way to achieve this goal using the regular expression?
CodePudding user response:
You may use this regex:
\bse\b|\(se\)
RegEx Details:
\b
: Match word boundaryse
: Matchse
\b
: Match word boundary|
: OR\(
: Match opening(
se
: Matchse
\)
: Match closing)