Notepad++ – How to Remove Lines That Start with Text using Find and Replace

This guide shows how to remove lines that start with specific text in Notepad++ using Find and Replace with a regular expression.

Table of contents

Caution: Back up your file before using Replace All.

Find and Replace Values

This example finds lines that start with ![Node and removes them (replaces with “”).

Steps

  1. Open your file in Notepad++.
  2. Open Search > Replace or press Ctrl+H.
  3. In Find what, enter:
    ^!\[Node .*$\R?
  4. Leave Replace with empty.
  5. At the bottom of the window, set Search Mode to Regular expression.
  6. Leave . matches newline unticked.
  7. Click Find Next once to make sure the correct line is selected.
  8. Click Replace to test one result, or click Replace All to remove every matching line in the file.
  9. The message at the bottom of the window will confirm how many occurrences were found and replaced.

Other examples:

Remove lines that start with "ERROR: "

  1. In Find what, enter:
  2. ^ERROR:.*$\R?

Find and replace with other text

This example replaces the text with "NEW TEXT".

  1. In Replace with, enter:
  2. NEW TEXT

How this regular expression works:

  • ^ means the match must start at the beginning of a line.
  • \[ tells Notepad++ to treat [ as normal text.
  • .*$ matches the rest of that line.
  • \R? removes the line break as well, so you do not leave an empty blank line behind.
  • This removes the whole line, not just the starting text.

Leave a Comment

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