How to exclude folders which contain a pattern except when under a certain folder?
How to exclude folders which contain a pattern except when under a certain folder?
I want to exclude all \node_modules\ folders from search but include it if it's under a certain folder. How do I do this?
Re: How to exclude folders which contain a pattern except when under a certain folder?
Please try the following negative lookahead regex exclude filter:
regex:^(?!c:\\foldera|d:\\folderb|e:\\folderc).*\\node_modules$
where c:\\foldera, d:\\folderb and e:\\folderc are the folders to keep.
Use double backslash (\\) for a single literal backslash with regex.
Add this as an exclude filter under Tools -> Options -> Exclude -> Add filter
-or-
Add this as a result omission under Index -> Add Omit Result Filter...
Tools -> Options -> Exclude will exclude these files/folders from your index and require a database rebuild.
Add Omit Result Filter can be toggled instantly and doesn't require the rebuild.
regex:^(?!c:\\foldera|d:\\folderb|e:\\folderc).*\\node_modules$
where c:\\foldera, d:\\folderb and e:\\folderc are the folders to keep.
Use double backslash (\\) for a single literal backslash with regex.
Add this as an exclude filter under Tools -> Options -> Exclude -> Add filter
-or-
Add this as a result omission under Index -> Add Omit Result Filter...
Tools -> Options -> Exclude will exclude these files/folders from your index and require a database rebuild.
Add Omit Result Filter can be toggled instantly and doesn't require the rebuild.