30

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"

Craig Smitham
  • 2,765
  • 4
  • 26
  • 34
  • 1
    Probably `^(?![\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
  • 1
    May 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 Answers2

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
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