How to find a files with multiple instances of substring in Pycharm search

Viewed 13

I need to search through the whole Project files where "sub_string" appears twice (might appear on different lines).

I tried

(sub_string){2}

but it seems that it'd work only in case this text appears twice in sequence: "...sub_stringsub_string..."

So how to search for files where substring appears twice and not in sequence?

1 Answers

One way to do this if you only specifically want 2 instances is with the following:

.*sub_string.+sub_string.*

This doesn't scale nicely manually if you want more than 2 occurrences, but you can always use a loop to generate the regex string and go from there.

An example can be found here.

Related