BBEdit-compatible regex for remove blank lines

Viewed 13660

i've tried other regexes that are supposed to be able to remove blank lines from a document, but none of them seem to work within BBEdit's find-and-replace.

What is a regex for stripping blank lines from a document that will work in bbedit?

7 Answers

Find: \r+ Replace with: \r

Grep option should be checked.

BBEdit.. Text --> process duplicate lines. Delete duplicate lines

For truly blank lines in BBedit, I search for:

^$\r

and replace with nothing. This finds the blank lines and removes the contents of the line and the linefeed.

An alternative I have used when I forget how to match a linefeed is to use:

.+ 

…to match one or more characters and then use the extract button rather than replace all. Instead of deleting your blank lines, you are keeping any line with something on it.

Related