- For searching lines with only a single word .
^\h*\w+\h*$- ^ - Start of line
- \h* - optional leading horizontal whitespac
- \w+ - 1 or more word symbols You can use \S instead of \w to match any non-whitespace symbols.
To insert a linebreak, just replace with \r\n$0. You do not need any capturing groups since you can always reference the whole match with
- Find empty lines
-
^\s*$
-
Explanation:
- ^ is the beginning of string anchor.
- $ is the end of string anchor.
- \s is the whitespace character class.
-
- is zero-or-more repetition of. In multiline mode, ^ and $ also match the beginning and end of the line.
References:
regular-expressions.info/Anchors, Character Classes, and Repetition.