Sanuuu
Sanuuu

Reputation: 243

How to use Sublime Text's "Find in Files" to find files containing multiple different strings?

I have string1 and string2 and a bunch of text files in a folder. The files may contain any number of occurrences of string1 or string2.

Is there a way to use Sublime Text's "Find in Files..." utility to find all files containing at least one occurrence of each?

Looking into the subject I've been able to find a way to search for the or of multiple strings (i.e. matching either matches the entire file), but what I'm trying to do is an and. On the other hand using non-consuming regular expressions as suggested in this answer simply doesn't seem to work in Sublime Text 2 (always yields zero matches).

Upvotes: 2

Views: 2500

Answers (1)

Enteleform
Enteleform

Reputation: 3823

This RegEx pattern will enable you to find files which contain each of your string queries: (string1[\s\S]*string2)|(string2[\s\S]*string1)

[\s\S]* is used to match any character ( including line breaks ) as many times as necessary until the following set of characters is found.

Multiple Query RegEx Pattern

Upvotes: 5

Related Questions