Search for the regex \{(?![^}]*not)([^}]+)\}
And replace with $1
or \1
based on your regex engine(or the function).
In the regex (?![^}]*not)
is a negative lookahead that is checking that there is no not
inside the {}
.
Try it at regex101.
Pergunta
I want to a regex expression to replace the following string
{match1}{matchb}{not}{anotb}
with
match1matchb{not}{anotb}}
How to write the regex expression.
Basically I want to find a string inside {}
but the string can not contain not
.
Solução
Search for the regex \{(?![^}]*not)([^}]+)\}
And replace with $1
or \1
based on your regex engine(or the function).
In the regex (?![^}]*not)
is a negative lookahead that is checking that there is no not
inside the {}
.
Try it at regex101.
Outras dicas
You can match this:
\{([^}]*)\}\{([^}]*)\}\{not\}
and replace with:
\1\2{not}