Hey Guys,
Let's make that just a trifle more robust.
Sometimes horizontal whitespace can sneak into what you think are empty blank lines, and you may also want to prevent the last line from having a linefeed.
JM's pattern has the advantage of simplicity and of taking any line endings and ensuring they end up being linefeeds, but you would need a second pass to remove the last linefeed (if desired).
The regular expression below REQUIRES macOS 10.11 or later.
RegEx ⇢ String ⇢ Test KM Find & Replace RegEx.kmmacros (2.8 KB)
-Chris