Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++ Regex to find multiple words in a document?

I am looking for the following words in my document:

"substr" 
"500"
"description"

I am using the following expression to try and match this:

(substr|500|description)

That works to find any of these words, but I want to jump to lines that only contain ALL of these words. Is there any way to do this? I don't want an OR condition, I want to AND on all of these words.

So for example:

test substr line one
test substr, 500 line two
test substr, 500, description line three <<--- only go to this line when I hit next!!

Is this possible?

like image 634
Hooplator15 Avatar asked Mar 12 '23 04:03

Hooplator15


1 Answers

To match them in any order you can use positive lookaheads ?=:

((?=.*\bsubstr\b)(?=.*\b500\b)(?=.*\bdescription\b).*)

To match them in the given order is much easier:

.*substr.*500.*description.*
like image 101
Andy G Avatar answered Mar 24 '23 05:03

Andy G