I would like to use the "Find All in Current Document" button within Notepad++ to find all instances of a list of words. Is it possible to do this with a regular expression?
For example, if the list of words was
Foo,man,choo
and the file in notepad++ contained
01 The quick brown fox jumps over the lazy dog
02 The quick brown fox jumps over the lazy dog
03 The quick brown man jumps over the lazy dog
04 The quick brown fox jumps over the lazy dog
05 The quick brown fox jumps over the lazy dog
06 The quick brown foo jumps over the lazy dog
07 The quick brown fox jumps over the lazy dog
08 The quick brown fox jumps over the lazy dog
09 The quick brown choo jumps over the lazy dog
10 The quick brown fox jumps over the lazy dog
Lines 3,6 and 9 would be returned in the find results.
To run a “whole words only” search using a regular expression, simply place the word between two word boundaries, as we did with ‹ \bcat\b ›. The first ‹ \b › requires the ‹ c › to occur at the very start of the string, or after a nonword character.
Using Regex to find and replace text in Notepad++ A quick cheat sheet for using Notepad++ to find and replace text in Notepad++. In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string). And also ensure the 'Regular expression' radio button is set.
Notepad++ supports pipes operator |
since 6.1.1 version.
You can use this regex for your search :
^.*(Foo|man|choo).*$
If you want to just match these words then you can use
(foo|man|choo)
Result:
foo
man
choo
But if you want to match entire line which contains one of these words you could use
^.*(foo|man|choo).*$
Result:
03 The quick brown man jumps over the lazy dog
06 The quick brown foo jumps over the lazy dog
09 The quick brown choo jumps over the lazy dog
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