find some text AND NOT other text

Tool for Search and Replace across multiple files.
Post Reply
4EverMaAT
Posts: 19
Joined: Tue Sep 24, 2019 4:07 pm

find some text AND NOT other text

Post by 4EverMaAT »

For example, I want to find "Monetary" but exclude that find if the word "Union" comes immediately afterwards.

1 AUD Australia 3 Monetary Policy Meeting Minutes
2 EUR European Monetary Union 2 EcoFin Meeting
3 EUR European Monetary Union 1 ZEW Economic Sentiment
4 EUR European Monetary Union 1 Non-Monetary Policy ECB Meeting FxStreet

Lines 1 (Monetary Policy.....) and Line 4 (Non-Monetary Policy....) is ok.

But Lines 2, 3 (Monetary Union) I want to ignore. There is no other mention of Monetary in that line.

I assume I might need to use regex.
User avatar
DigitalVolcano
Site Admin
Posts: 1717
Joined: Thu Jun 09, 2011 10:04 am

Re: find some text AND NOT other text

Post by DigitalVolcano »

Negative lookahead Regular Expression should do it-

Regex:

Code: Select all

Monetary(?! Union)
4EverMaAT
Posts: 19
Joined: Tue Sep 24, 2019 4:07 pm

Re: find some text AND NOT other text

Post by 4EverMaAT »

DigitalVolcano wrote: Fri Jan 31, 2020 11:05 am Negative lookahead Regular Expression should do it-

Regex:

Code: Select all

Monetary(?! Union)
These type of examples need to be included in the regex reference guide. Or you can point to a good online reference guide. I will also link to this for the 4.x suggestion.
Post Reply