Visual Studio Code - Removing Lines Containing criteria

This probably isn't a VS Code-specific question but it's my tool of choice.

I have a log file with a lot of lines containing the following:

Company.Environment.Security.RightsBased.Policies.RightsUserAuthorizationPolicy

Those are debug-level log records that clutter the file I'm trying to process. I'm looking to remove the lines with that content.

I've looked into Regex but, unlike removing a blank line where you have the whole content in the search criteria (making find/replace easy), here I need to match from line break to line break on some criteria between the two, I think...

What are your thoughts on how criteria like that would work?


Solution 1:

If the criteria is a particular string and you don't want to have to remember regexes, there is a few handy keyboard shortcuts that can help you out. I'm going to assume you're on a Mac.

  1. Cmd-F to open find.
  2. Paste your string.
  3. Alt-Enter to select all of the instances of the string on the page.
  4. Cmd-L to broaden the selection to the entire line of each instance on the page.
  5. Delete/Backspace to remove those lines.

Solution 2:

I think you should be able to just search for ^.*CONTENT.*$\n, where the content is the text you showed us. That is, search on the following pattern:

^.*Company\.Environment\.Security\.RightsBased\.Policies\.RightsUserAuthorizationPolicy.*$\n

And then just replace with empty string.