find some text AND NOT other text

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

find some text AND NOT other text

Post by 4EverMaAT » Fri Jan 31, 2020 9:44 am

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: 1290
Joined: Thu Jun 09, 2011 10:04 am

Re: find some text AND NOT other text

Post by DigitalVolcano » Fri Jan 31, 2020 12:05 pm

Negative lookahead Regular Expression should do it-

Regex:

Code: Select all

Monetary(?! Union)
Post Reply