Sherzod
Sherzod

Reputation: 5131

Searching for multiple keywords in the same file within bigger project in Sublime Text 3

I would like to search a whole project for files that have both ABCKeyword and XYZKeyword in the same file. Is this possible?

When I search a whole project with regex (ABCKeyword|XYZKeyword), it returns files that have one or the other but not necessarily both.

Upvotes: 1

Views: 189

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626845

You can use positive look-aheads:

(?s)^(?=.*\bABCKeyword\b)(?=.*\bXYZKeyword\b)

Only the text that has both will be matched.

See demo

(?s) makes the . to match a newline symbol. (?=.*...) look-aheads check, but do not consume characters, thus only asseting if there is ABCKeyword or XYZKeyword further in the text. The \b word boundaries make sure we only match full words (if you need to match them partially, inside longer words, remove \bs).

Upvotes: 1

Related Questions