Keep Or Remove Lines Containing

Filter your text by keeping or removing lines that contain specific text or patterns

When You Need This

  • Filtering log files for specific events or errors
  • Cleaning data by removing unwanted entries
  • Extracting specific information from large text files
  • Processing lists to keep only relevant items
  • Removing empty or malformed lines from data

How to Use This Tool

  1. Enter your text - Paste or type your content, with each item on its own line
  2. Specify filter text - Enter the text or patterns you want to match (one per line)
    • ☑️ Multiple patterns will be checked for each line
    • ☑️ Leave empty to match all lines (when keeping) or no lines (when removing)
  3. Choose action - Decide whether to keep or remove matching lines
  4. Set match type:
    • ☑️ Contains text: Line contains the specified text anywhere
    • ☑️ Exact match: Line matches exactly (including whitespace)
    • ☑️ Starts with: Line begins with the specified text
    • ☑️ Ends with: Line ends with the specified text
    • ☑️ Regular expression: Advanced pattern matching
  5. Set options:
    • ☑️ Case sensitive: Match exact letter casing
    • ☑️ Invert match: Keep lines that don't match your criteria
  6. Click "Filter Text" - Your filtered text will appear below
  7. Copy or download - Use the result directly or save it for later

Example Workflow:

1. You enter:
apple pie
banana bread
cherry tart
blueberry muffin

2. Set filter text to berry

3. Choose "Keep matching lines"

4. Output becomes:
blueberry muffin

Advanced Usage Tips

  • Use regular expressions for complex pattern matching
  • Combine multiple filter terms to create sophisticated filters
  • Use the invert option to quickly find lines that don't match your criteria
  • Process log files by filtering for specific error codes or timestamps
  • Clean CSV data by removing malformed or incomplete rows

Common Questions

Can I filter using multiple criteria at once?

Yes! Enter multiple terms (one per line) in the filter text area. A line will match if it meets any of the criteria (OR logic).

What's the difference between "Remove matching lines" and "Invert match"?

"Remove matching lines" removes lines that match your criteria, while "Invert match" changes the matching logic itself. For example, with "Contains text" and invert match, it will match lines that don't contain the text.

Can I use regex with the other match types?

No, regular expressions are only available when you select the "Regular expression" match type option.