Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BBEdit-compatible regex for remove blank lines

Tags:

regex

bbedit

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?

like image 833
Jack Cooper Smith Avatar asked Aug 09 '12 21:08

Jack Cooper Smith


People also ask

How do I delete blank lines in BBEdit?

Check the "Use grep" and "Delete matched lines" box. Uncheck all others. There is no 'Delete matched lines' option in BBEdit 12. Your method only works on lines containing at least one space symbol.

How do I remove blank lines in a text file?

Open TextPad and the file you want to edit. Click Search and then Replace. In the Replace window, in the Find what section, type ^\n (caret, backslash 'n') and leave the Replace with section blank, unless you want to replace a blank line with other text. Check the Regular Expression box.

How do I delete blank lines in Notepad++?

First you need to open the file with Notepad++. Once the document is loaded, select Edit > Line Operations > Remove Empty Lines. Voilà, every single blank lines has been deleted.


2 Answers

I'm going to assume that there may be whitespace in the lines you wish to remove. This should do the trick:

^\s*?\r

(replace with nothing, make sure the "Grep" checkbox is ticked)

like image 157
steveax Avatar answered Oct 05 '22 06:10

steveax


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

like image 36
Rama Suresh A Avatar answered Oct 05 '22 05:10

Rama Suresh A