I have a piece of software that, given a regex, can perform a find and replace. It's not a coding language, so no suggestions other than regex will be useful. I have searched looking for an expression that will help me find all text except "pattern". The pattern is not necessarily at the start or the end of the string, and can occur multiple times. Given the string:
red blue yellow green orange purple blue black green white
and a pattern:
blue.*?green
a pattern that appears twice on the line, I am trying to select everything but. (with a view to removing the selected and leaving just the pattern). I have tried:
FIND - ".*?(blue.?green)"
REPLACE - "$1",
but that still leaves "white" on the end. Any help would be appreciated.
It's usually something like this
Find (?:(?!blue.*?green).)*(blue.*?green)?
Replace $1
Expanded
(?:
(?! blue .*? green )
.
)*
( blue .*? green )? # (1)
Output
blue yellow greenblue black green
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With