Regex for blank lines

/^\s*$\n/gm

Options
Matches

Examples

Note

Replace with nothing to delete empty and whitespace-only lines.

Matches in the example

  • "\n \n"
  • "\n"

Token by token

  1. ^ the start of the string (or line, with the m flag)
  2. \s* a whitespace character, zero or more times, as many as possible
  3. $ the end of the string (or line, with the m flag)
  4. \n a line feed

Other patterns