0

I need to

  1. find certain lines in my code base and
  2. display the results in Visual Studio's "Find Results".

That's what the "Find in Files" search window is here for, right?

However, the catch is that I need to apply multiple regular expressions to find the "problematic" lines, e.g., I need all lines which match regular expression A, but do not match regular expressions B and C.

What I've tried:

  • I thought about searching for A, exporting the result to a file and then grep/findstr-ing it against B and C, but then I lose the ability to see the results in Visual Studio's "Find Results" window (which I need, because I want to click on the line and investigate each match further).

  • The regular expressions A, B and C are complex enough for me to be unable to merge them into a single expression. You are welcome to try (ping me in the comments), but even if this solves my current problem, I am interested in a general solution for the next time I have this issue.

So far, the only workaround I can think of is to use "Replace in Files" to annotate lines matching A and then use "Replace in Files" again to remove the annotation from lines matching B and C, but I was wondering if there is a more elegant solution that I have missed...

Heinzi
  • 167,459
  • 57
  • 363
  • 519
  • Have you thought about lookarounds, sth. like `(?!B)(?!C)A` (in pseudo-code obviously). – Jan Jul 17 '19 at 15:16
  • @Jan: Yes, I have, but I've been unable to find a generic solution for that problem. It's a good question, so I have [started a new question for that](https://stackoverflow.com/q/57098751/87698). – Heinzi Jul 18 '19 at 16:11

0 Answers0