In Visual Studio Code, using the search capability, how can I search for all files that do not contain a certain string? In this case - "OnPush"
Asked
Active
Viewed 2.6k times
30
-
1Probably `^(?![\S\s\r]*OnPush)`, but I can't test now. – Wiktor Stribiżew Jul 11 '18 at 23:07
-
2@WiktorStribiżew when I enable Regex and try that, as well as other possible regex solutions, VS code responds with "Expression Matches Everything" – Craig Smitham Jul 11 '18 at 23:16
-
1May want to check info on the regex flavor first https://stackoverflow.com/questions/42179046/what-flavor-of-regex-does-visual-studio-code-use – Jul 11 '18 at 23:33
2 Answers
29
In general regex, to search for anything that does not contain a certain string, you do stringbefore(?!string) That is a negative lookahead, it says that only match if whatever you specify as string is not present. In your case it would be something like [\W\w]+(?!OnPush)
But, Negative Lookaheads aren't supported in VS Code Search... So you can't do much.
Sheshank S.
- 2,823
- 3
- 17
- 36
-
-
1Negative look-ahead isn't supported in VS Code search: https://github.com/Microsoft/vscode/issues/30735 – jabacchetta Jul 12 '18 at 01:23
-
8You need to enable "search.usePCRE2" in VS Code to use negative look-ahead. – Ali Yousuf Mar 15 '19 at 19:54
-
4You don't need to ensable the `PCRE2` setting anymore - in fact it is deprecated. Vscode will use PCRE2 as a fallback automatically now. – Mark Oct 21 '19 at 20:50
-
2VSCode (v 1.50.1) Search works. e.g search for a comma not followed by whitespace `,(?!\s)`. – s3c Nov 03 '20 at 12:55
8
There is a VS Code extension called Reverse Search It can find files that do not contain a specific string
Danish Sarwar
- 317
- 2
- 8
-
2Is it possible to search only in specific folder and in specific files like .php? – Ivan Topić Jan 13 '20 at 10:19
-
@IvanTopić yes, you can include or exclude files using this extension. – Danish Sarwar Feb 25 '20 at 04:50