This is the inverse of pattern-based removal: lines matching the expression are kept and everything else is discarded.
Choosing the direction
Keep when the wanted set is smaller or easier to describe than the unwanted one. Remove when the opposite is true. Describing the smaller set produces a simpler, safer pattern.
Typical use
Isolating all URLs under a directory, all keywords containing a number, or all rows whose identifier follows a particular format.
Verify by counting
Compare the line count before and after. If the kept set is far larger or smaller than expected, the pattern is matching something you did not intend.
Try it: Keep Lines Matching Regex on SeoWolf's Notepad.