Recently I needed to clean up a pile of text I had pasted into emacs from a pdf. One of the things I wanted was to remove all lines that didn’t start with a comma. Emacs of course provides functions for this, so I highlighted the text and used M-x delete-non-matching-lines ^,
The ^,
is a regular expression that matches lines starting with a comma. Emacs also offers the command delete-matching-lines
which does what you would expect.
Just a note to say that delete-non-matching-lines is an alias for keep-lines; delete-matching-lines is an alias for flush-lines.
LikeLike