Hoody
Hoody

Reputation: 3381

Is there a regular expression to find one of several words in Notepad++

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.

Upvotes: 7

Views: 24154

Answers (3)

zessx
zessx

Reputation: 68790

Notepad++ supports pipes operator | since 6.1.1 version.

You can use this regex for your search :

^.*(Foo|man|choo).*$

Upvotes: 18

Vaman Kulkarni
Vaman Kulkarni

Reputation: 3451

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

Upvotes: 11

Billy Moon
Billy Moon

Reputation: 58531

This should do it - using the or operator... might work without the brackets too.

(Foo|man|choo)

Upvotes: 1

Related Questions