Remove Lines Containing

Delete every line that contains (or does not contain) a specific word, phrase, or pattern. Case-sensitive matching, regex support, and multi-pattern filtering. Useful for log cleanup, list filtering, and prose pruning. Runs in your browser.

Input Load sample

How to filter lines by match

1. Paste your text

Drop your text into the Input box. The tool operates line by line: each line is checked against the pattern independently. Pasted log files, CSVs, email lists, code, and prose all work the same way.

2. Set the pattern

Type the word, phrase, or regex into the Pattern field. For multiple patterns, put one per line. The Match policy controls whether a line is filtered if any pattern matches or only if all patterns match the same line.

3. Pick mode

Remove matching deletes lines that match (default; what most users want). Keep matching only inverts the filter: only matching lines stay. The latter is useful for grep-style log filtering.

4. Tune options and filter

Case sensitive requires exact case. Whole word only requires the pattern to appear as a complete word, not inside a longer word. Regex mode treats the pattern as a JavaScript regular expression. Click Filter or wait for the live preview.

When you need a line filter

Log file triage
Keep matching only mode + pattern ERROR shows only error lines from a server log. Add WARN as a second pattern with Any-policy to keep both errors and warnings.
Email list cleanup
Remove every line containing a specific domain (your test domain, a competitor) before exporting a contact list.
Comment stripping
Strip lines starting with # or // from a config or code file. Use Regex mode + ^[#/]+ for a one-pass cleanup.
Stop-word removal
Paste a wordlist, set the pattern to a list of stop words, run with Whole word only on. Output is the wordlist minus stop words.
Prose pruning
Remove every paragraph (treat blank-line-separated blocks as lines via the single-line-break mode of paragraph shuffler first) that contains a banned phrase.
CSV row filter
Filter spreadsheet rows by value in a column without opening the spreadsheet, when you just need a quick subset.

Regex patterns reference

Regex mode unlocks more precise matching. The Pattern field is parsed as a JavaScript regex (no leading and trailing slashes; no flag suffix). Useful patterns:

PatternMeaningExample match
^#Line starts with #"# comment", "## heading"
\\bERROR\\bWhole word ERROR"... ERROR ..." but not "ERRORS"
[0-9]{3}-[0-9]{4}3 digits, dash, 4 digitsPhone numbers like 555-1212
https?://http or https URLAny line containing a web link
^\\s*$Blank or whitespace-only lineFor pure-blank filtering; usually Remove Empty Lines is easier
.{200,}Lines with 200+ charactersFilter overly long lines

The Case sensitive toggle controls whether the regex gets the i flag. Patterns are joined with the policy logic in code, not in regex syntax, so do not try to use alternation (a|b|c) for multi-pattern logic; use the multi-line pattern field instead.

Filter recipes

GoalPatternMode + options
Keep only ERROR linesERRORKeep matching, Case sensitive on
Strip all comments^[#/]Remove matching, Regex on
Strip blank lines(empty Pattern)Better: use Remove Empty Lines
Remove rows containing test addresses@test.Remove matching
Keep lines with both ERROR and 500ERROR (line 1), 500 (line 2)Keep matching, All patterns

For more complex find-and-replace inside lines, use Word Replacer. For pure-blank-line stripping, see Remove Empty Lines.

Related tools

Frequently asked questions

How do I remove every line that contains a word?

Paste the text into the Input box. Type the word into the Pattern field. Leave Mode set to Remove matching. Click Filter. Every line that contains the word is removed and the rest stays in their original order.

How do I keep only the lines that contain the word?

Switch Mode to Keep matching only. The filter inverts: lines that do NOT contain the pattern are removed, lines that DO contain it are kept. Useful when you have a log file and want only the error lines.

Can I match multiple patterns at once?

Yes. Type one pattern per line in the Pattern field. Set Match policy to "Any pattern matches" (line is removed if any pattern is found) or "All patterns match" (line is removed only when every pattern is found in the same line).

Does this support regular expressions?

Yes. Turn on Regex mode. The Pattern field is then parsed as a JavaScript regex (without the leading and trailing slashes). Common useful regexes: ^# (comment lines), \\bERROR\\b (whole word match for ERROR), [0-9]{3}-[0-9]{4} (US-format phone numbers).

Is matching case-sensitive?

By default, no. "ERROR" matches "Error" and "error". Turn on Case sensitive to require exact case match. In regex mode, the i flag is added automatically when Case sensitive is off.

What does Whole word only do?

When on, the pattern matches only when it appears as a complete word, not as part of a longer word. So "cat" matches "the cat sat" but not "catalog" or "concatenate". In regex mode, this wraps the pattern with word boundaries.

Can I see what would be removed before committing?

The output shows the filtered text live as you type. The Diff toggle shows removed lines in red strikethrough above the kept lines, so you can sanity-check before copying. Diff view is read-only.

Is my text uploaded anywhere?

No. Filtering runs in client-side JavaScript. Input and output stay in the browser tab. We have no upload endpoint and we do not log content.

More wordcounter.ai tools

Other tools you might find useful.

Browse the full catalog →