Reputation: 21
I have a text:
"The quick brown fox jumps over the lazy dog"
and I need to match everything except the text between a word and the first occurrence of a letter after this word as follows (in this case between brown and the first occurrence of "l"):
"The quick brown lazy dog"
I have tried some possible solutions but the closest match I have in my hand is exactly the opposite:
(?<=brown ).*?(?=l)
which matches " fox jumps over the"
I am using Klipfolio tool and the exact text I have is like this:
["String1: value1","String2: value2","String3: value3"]
And I want to match all except value1 and replace it with empty string.
Function I am using is SUBSTITUTE_REGEX
Upvotes: 2
Views: 978
Reputation:
As mentioned, the simplest way is to do a string replacement.
To do the inverse is more involved and is done like this:
Find (.*?brown ).*?(l.*)|(.+)
Replace $1$2$3
https://regex101.com/r/x8QW6r/1
Upvotes: 1
Reputation: 24137
You can just use your original pattern and replace the matched part with an empty string ""
.
Alternative way to do this is to create two match groups, which you can then combine to get the wanted result:
(.*brown )(?:[^l]*)(.*)
Full match 0-43 The quick brown fox jumps over the lazy dog Group 1. 0-16 The quick brown Group 2. 35-43 lazy dog
Upvotes: 0