Reputation: 1550
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?
Upvotes: 4
Views: 6730
Reputation: 19367
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.*
Upvotes: 7