Saturday, 19 July 2008

Removing all blank lines from a file with regular expressions in Visual Studio or UltraEdit

I often deal with files which have redundant empty lines in them. These are easily removed by either Visual Studio or one of the best text editors around, UltraEdit by IDM Solutions. The regular expression criteria matching blank lines in these 2 applications are slightly different (the end of line escape character "$" appears in a different order in each):

Visual Studio:

Press Ctrl+G
Select "Use Regular Expressions"
In Find specify "^$\n" (without the quotes).
Set the replace value to blank.
Click on "Replace All"

UltraEdit:

[from the UltraEdit FAQ at at http://www.ultraedit.com/support/faq.html]

To delete/strip blank lines from DOS/Unix/Mac formatted-files, use the following Perl-compatible regular expression. You can enable Perl-compatible regular expressions under Advanced -> Configuration -> Search -> Regular Expression Engine.

Replace: "^\r?\n?$" (without the quotes)
With "" (without the quotes - i.e. nothing).

Earlier versions of UltraEdit:

To delete blank lines with DOS line terminators you can use an UltraEdit-style regular expression replace as follows:

Replace: "^p$" (without the quotes)
With "" (without the quotes - i.e. nothing).

Run this replace until every blank line is deleted.

9 comments:

  1. thank you, FYI, this works in Sharepoint Designer also

    ReplyDelete
  2. So nice I am enjoying for that post as for u latest version of this Security tool Available…MiniTool Partition Wizard Technician Crack 12 With Serial Key Latest 2020

    ReplyDelete
  3. THANKS FOR SHARING YOUR KNOWLEDGE TO INSTALL & CRACK THE ASC TIMETABLES, BUT YOU NEED TO UPDATE IT NOW BECAUSE THERE IS A 2020 VERSION AVAILABLE NOW: YOU CAN GET IT HERE:TRAKTOR PRO 3 FOR MAC FREE DOWNLOAD 2020

    ReplyDelete


  4. Voicemod Pro Crack
    I am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me

    ReplyDelete