delete lines containing $STRING in vscode

Needed to search  CSV file for a specific string, and delete any lines containing that string.  Strangely enough I was already looking at the file in VSCode so decided to use that for the replace.

 

Do a search and replace, select regex, and use the format

^.*($STRING).*\n?

Where wordToSearchFor is the word to remove the entire line of, and use a replace entry of blank.  ($STRING can’t contain a pipe character).

eg: ^.*(c:0u.c).*\n

The good thing about VSCode is it allows you to see the results of the query before performing the replace.

 

Leave a Reply

Your email address will not be published. Required fields are marked *