Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 3 - Search multiple folders with regex for files in one folder

I want to perform a search on all of the files in the /app/libraries and /app/views folders, but I only want to search within files starting with App in the /app/models folder.

If I use /app/libraries, /app/views, /app/models/App* it gives me:

/app/models/App*:
    ERROR: Unable to open file
0 matches

If I use /app/libraries, /app/views, /app/models, App* it only gives me files starting with App in all of the folders.

I've tried getting rid of the leading slash /app/libraries, /app/views, app/models/App* as suggested by this answer, but I get this:

Searching 0 files for "search string" (regex, case sensitive)

0 matches
like image 998
Katrina Avatar asked Sep 13 '25 16:09

Katrina


1 Answers

The point here is that you have been using wildcard pattern while you needed a regex pattern.

To match any amount of any chars in wildcard patterns, an asterisk is used, but in regex patterns, you may use either .* (any 0+ chars other than line break chars) or - if you need to only match App as part of the file name (and thus, no more / are allowed) - you may use [^/]* (zero or more chars other than /.

So, use either

/app/models/App.*

or

/app/models/App[^/]*
like image 173
Wiktor Stribiżew Avatar answered Sep 16 '25 09:09

Wiktor Stribiżew