araç köşesi

Remove Lines Containing a Word — Filter Lines Online

Delete every line that contains a word or phrase, or keep only those lines, with starts-with, ends-with and whole-line matching

Your data stays with you. Conversion happens inside the browser; nothing is sent to a server.

How it works

Paste your lines into the left box and type the word you are looking for in 'Search for'; the result appears on the right as you type. The default action is 'Remove matching lines': type 'error' and every line containing error disappears, while the others stay in their original order. Choose 'Keep only matching lines' for the opposite, which is how you pull the errors out of a log file. For several words, separate them with commas: 'error, warning' catches any line containing either. 'Where in the line' narrows the search: 'At the start of the line' only matches lines that begin with the word, and 'The whole line' only matches lines that consist of exactly that word. Case is ignored by default, so ERROR, Error and error all match; switch to 'Match case' when capitals matter. The search text is taken literally: a dot is a dot and an asterisk is an asterisk, no regular expressions involved. The status line tells you how many lines were removed and how many are left.

This tool is also known as remove lines containing, delete lines containing text, filter lines online, keep lines containing, grep online.

What is Line filtering (grep)?

Line filtering means going through a text line by line and keeping or discarding each line according to a rule. Programmers do it on the command line with grep: 'grep error' shows only lines containing error, and 'grep -v error' shows only lines without it. This tool does the same job without a terminal. The order of the lines never changes; the tool only decides which lines survive and never edits the text inside a line.

What is Case sensitivity?

Case sensitivity decides whether a search treats 'Error', 'ERROR' and 'error' as the same or as different. A case-insensitive search matches all three; a case-sensitive one matches only the exact spelling. Case-insensitive matching is usually done by lowercasing both texts before comparing them, and lowercasing depends on the language: in Turkish the lowercase of I is a dotless ı. This tool lowercases according to the language of the page.

What is the difference between filtering lines and Find and Replace?

Find and Replace changes text inside a line: it turns 'error' into 'warning' but leaves the line where it is. Filtering decides about whole lines: if the search term appears, the line is either removed entirely or becomes one of the only lines kept, and its content is never edited. Deleting lines with Find and Replace requires writing a regular expression; this tool gets the same result without one. Use Find and Replace to correct content, and this tool to pull lines out of a long list.

Typical uses

Filtering is the fastest way to pull the lines you want out of a long list, or to throw away the ones you don't. By hand you would read hundreds of lines and miss some; the tool applies the same rule to every line and counts how many went.

  • Keep only ERROR lines from a server log
  • Remove every address from one domain (gmail.com) in an e-mail list
  • Delete 'out of stock' lines from a product list
  • Drop 'N/A' answers from exported survey responses
  • Keep only rows for one city from a pasted spreadsheet column

Literal search, not regex

Most command-line and code-editor tools for this job expect a regular expression, where characters such as . * ? ( ) and [ have special meanings. Search for '3.5' with a regex and you also match '305' and '3-5'. This tool searches for exactly what you type, which is what most people expect.

If you do need patterns, such as lines that start with a digit or contain an e-mail address, use the Find and Replace tool with regex enabled. For simple word filtering, literal matching is safer and gives no surprises.

Frequently asked questions

Can I use regular expressions?

No, on purpose. The text is matched literally. For pattern searches use the Find and Replace tool, which supports regex.

How do I search for several words at once?

Separate them with commas in 'Search for': 'error, warning, critical'. A line matches if it contains any of them.

Can I search for a phrase that contains a comma?

Not as one term: the comma splits search terms, so a comma inside the phrase splits it too. Search for a part of the phrase without the comma instead.

What happens to empty lines?

An empty line contains no word, so it stays when you remove matching lines and is dropped when you keep only matching lines. To clean up empty lines separately, use the Clean Up Text tool.