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?
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?
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)
I find it easier to choose "Text>Process lines containing..." with the expression:
^$
or
^\s*$
Check the "Use grep" and "Delete matched lines" box. Uncheck all others.
*
should match zero or one. What's up there? Looks like the $ requires a second line -- when I did a search & replace with the same regex (^\s*$
), it removed all but the last line in each batch of empty lines. –
Nomothetic This works in Coda. (Not sure about BBEdit though)
Find:
\n\n
Replace with:
\n
Make sure the "Use Regular Expressions" option is checked.
Find: \r+ Replace with: \r
Grep option should be checked.
BBEdit.. Text --> process duplicate lines. Delete duplicate lines
To remove all blank lines whatever the amount of blank lines between not blank lines, whatever the amount been regular or not.
You must proceed that way:
1st you remove all the blank lines with
« Text Menu / Process Lines Containing... »
> Regex : ^$
> Use grep enabled
> Delete matched line enabled
2d if you want to recover legibility add a blank line after your blocks for instance
« Search Menu / Find... »
> Grep enabled
> Find: ^}$ <<<< because the final curly is usually the 1st and the last char
> Replace: }\n <<<< or \r or \r\c according to the Platform choice
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.
© 2022 - 2024 — McMap. All rights reserved.