delete blank lines

Tool for Search and Replace across multiple files.
Post Reply
User avatar
ulopez

delete blank lines

Post by ulopez »

which regular expression I can use to eliminate blank lines before and after a text?
User avatar
DV

Post by DV »

To delete blank lines in TextCrawler use the following regular expression-
^\r?\n?$
and replace with nothing.

Try it in the regex test first if you are not sure.

User avatar
ubiet

Post by ubiet »

thanks
but, if for example I has the following text:

"end if
User avatar
ubiet

Post by ubiet »

thanks
but, if I only need eliminate the blank lines that are before or after a specific text. how can I do it.

User avatar
DV

Post by DV »

Deleting after a specific text is something like-

regex: foo[\r\n]*
replace: foo\r\n
User avatar
John

Post by John »

Hello! Thanks for this wonderful app! My question: how can i remove more than two empty lines?

Example:

abc
abc


abc
abc

to turn to

abc
abc

abc
abc

Thanks in advance :)
User avatar
Fool4UAnyway

Post by Fool4UAnyway »

Try something like:
^((\r\n?|\n))(\r\n?|\n)+$

Replace with:
$1
User avatar
John

Post by John »

thanks fool4uanyway. I tried ^\r\n^\r\n and it worked fine :D
User avatar
Fool4UAnyway

Post by Fool4UAnyway »

If you rerun the replacement, or just scan after the first pass, does it still find matches?
Post Reply