4

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
Katrina
  • 1,922
  • 2
  • 24
  • 42

1 Answers1

3

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[^/]*
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563