I have a requirement in which I want cater operators as normal terms when they are in quotes.
For example:
input string
"acquired GE Plastics" GE Mortors
(Acquired GE Plastics) GE Mortors
The regex should match the term GE
which is not wrapped in quotes/brackets. I am replacing this value to wrap it in quotes separately.Thus my resulting string will look like
Results:
"acquired GE Plastics" "GE" Mortors
(Acquired GE Plastics) "GE" Mortors
And the code snippet which I'm using to get the above result is
str.replace({working-regex}, '\"GE\"');
I have two regex which serves the problem in parts. Firstly, the regex to get to match all GE terms \bGE\b
and secondly the regex to match GE term wrapped in quotes ".*?(\bGE\b).*?"
. But I'm quite getting a way to add a not operator to exclude the match result from my second regex.