Filter Lines (Keep or Remove Lines Containing)
Keep or delete lines that contain, start with, end with or match words or a regular expression, or keep the first, last or every Nth line. Works on lines or paragraphs.
A browser version of grep, head and tail for when you have a log file, a list or a CSV export and only some lines matter. Keep or delete every line that contains a word, starts or ends with something, is exactly a given value or matches a regular expression, with several terms at once. Or cut by position: the first or last N lines, a range of line numbers, or every Nth line. Paragraph mode does the same for blocks of text separated by blank lines.
How to use this tool
- Paste the text.
- Choose whether matching lines are kept or removed.
- Choose how lines are matched and type the words or patterns, one per line, or set N and the line numbers for position-based filters.
- Copy the filtered text; the note shows how many lines were kept and removed.
Formula
Kept line = (line matches) XOR (action is “remove”) · Every Nth from line S keeps lines S, S + N, S + 2N …
With several terms, “any” keeps a line that matches at least one term and “all” only lines that match every term. Matching ignores capital letters unless “match case” is ticked, and whole-word matching treats letters, digits and the underscore as word characters in every script. Regular expressions use JavaScript syntax and run on one line at a time. Patterns with a repeat inside a repeat, such as (a+)+, or a repeated choice whose options can match the same text, such as (a|aa)+, can take exponentially long and are refused unless you allow them.
Example
With the sample log, keeping lines that contain ERROR or WARN leaves 3 of 6 lines: the two payment timeouts and the disk warning. Switching the action to “remove” keeps the other three lines instead, and “first N” with N = 2 keeps just the first two log entries.
Frequently asked questions
How do I delete all lines that contain a certain word?
Choose “Remove them” and “Contain”, then type the word. Add more words on separate lines to remove lines that contain any of them.
Can I use this like grep -v or grep -E?
Yes. “Remove them” with a pattern is grep -v, “Match a regular expression” is like grep -E, and leaving “Match case” off is grep -i. “First N” and “last N” do what head and tail do.
Why does my regular expression match too much?
Each pattern is searched anywhere in the line. Add ^ and $ to anchor it to the start and end, as in ^\d+$ for lines that are only digits.
Last updated:
Page address with these inputs: https://kakao.mobile/tools/remove-lines-containing-tool/
Cite or embed this tool
kakaoCalc. (2026, November 8). Filter Lines (Keep or Remove Lines Containing). https://kakao.mobile/tools/remove-lines-containing-tool/
“Filter Lines (Keep or Remove Lines Containing).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/remove-lines-containing-tool/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms