πŸ“š General & Other

Remove Lines Matching a Regular Expression

Where a plain substring filter matches fixed text, a regular expression matches a described pattern. That is the difference between removing lines containing and removing lines containing any…

Where a plain substring filter matches fixed text, a regular expression matches a described pattern. That is the difference between removing lines containing 2019 and removing lines containing any four-digit year.

What a pattern buys you

One expression can express a rule that would otherwise need dozens of individual filters β€” any line containing a date, any line ending in a file extension from a set, any line with a number in a particular position.

The cost

Regular expressions are genuinely easy to get wrong, and a wrong pattern removes the wrong lines without complaining. Test on a sample before running it over the whole list.

When a simple filter is better

If the thing you are removing is fixed text, use a plain filter. Reach for a pattern when the target genuinely varies.

Try it: Remove Lines Matching Regex on SeoWolf's Notepad.