Format Code Now
/
TextFilter Lines Next: Text Repeater ›

Remove Lines Containing Text

TX-20

Put -- text: and your search on the first line, paste the lines below it, then choose to keep or remove the lines that contain it.

Runs in your browser. Nothing is uploaded.

First line: -- text: what to find. Then the lines to filter

Filtered lines

How to use it

  1. On the first line type -- text: followed by the word or phrase, for example -- text: error
  2. Paste the lines to filter underneath, one per line.
  3. Tick Match case or Treat the search as a regular expression if you need them.
  4. Press Keep matching lines or Remove matching lines.
  5. Copy the result or download it as a .txt file.

How the search line works

The first line is a directive and is not part of the output. Everything after -- text: is the search, with spaces at both ends trimmed. A plain search matches anywhere in a line and ignores case unless Match case is ticked. Each line is tested alone, so a match never spans two lines. Keep matching lines returns the lines that match, and Remove matching lines returns the ones that do not, both in the original order.

Using a regular expression

With the regular expression option on, the search is a JavaScript pattern tested against each line. Use ^ and $ to anchor it, so -- text: ^2026 keeps lines starting with 2026. The case option still applies. An invalid pattern stops with an error that repeats the pattern and what the engine said. A pattern that backtracks a lot can make the page slow on very long lines, so keep patterns simple.

Error messages and what to do

MessageWhat it meansFix
Start the first line with -- text: followed by what to look for, for example -- text: errorThe first line does not start with -- text:.Add a first line such as -- text: error and put the lines to filter below it.
Nothing to look for after -- text: on the first line.The directive is there but the search text is empty.Type the word or pattern after -- text: on the same line.

Questions people ask

How do I remove lines containing a word?

Type -- text: and the word on the first line, paste your lines below it, and press Remove matching lines. Every line that contains the word is dropped and the rest stay in order.

How do I keep only lines that contain a word?

Use the same first line and press Keep matching lines instead. The output holds only the lines that contain your text, which works like a basic grep for pasted text.

Is the search case sensitive?

Not by default, so a search for error also finds ERROR and Error. Tick Match case when capitalization matters, for example to find a constant name but skip the same word in prose.

Can I filter with a regular expression?

Yes. Tick the regular expression option and put the pattern after -- text:. It uses JavaScript regular expression syntax, so lookaheads, alternation with | and character classes work. The pattern is tested against each line on its own.

Why do I get an error about the first line?

The tool needs to know what to search for, and it reads that from a first line starting with -- text:. Add that line, or check that nothing comes before it, then run it again.

About this tool

The first line is a directive, -- text: followed by the text to look for, and it is not part of the output. Every other line is tested on its own. Plain search matches anywhere in the line and ignores case unless you tick Match case. With the regular expression option, the pattern uses JavaScript syntax and matches anywhere in the line, so use ^ and $ to anchor it; an invalid pattern gives an error. A pattern that backtracks heavily can make the page slow on long lines. Surrounding spaces in the search text are trimmed, so a search for a word with a leading space is not possible. Empty lines never match unless the pattern matches an empty string.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.