Msg#: 3284810 posted 5:12 pm on Mar 17, 2007 (gmt 0)
Is there an easy way to delete blank lines in a long HTML document using Notepad? When I look at the source code it has for some reason developed long sections of blank lines in between the lines of text. This hasn't affected the way the HTML page displays though. It just makes it very difficult to edit. Any help in working out the answer to this will be much appreciated!
Msg#: 3284810 posted 5:54 pm on Mar 17, 2007 (gmt 0)
Using a better text editor would be a start. Textpad gets plenty of votes from experienced folk here, due to the regular expression support. This means you can search and replace very easily.
To get rid of extra blank lines in Textpad you would press F8 for 'search and replace' then pop \n\n into the find box, \n into the replace box and then make sure the tickbox for 'regular expression' is ticked, then press replace all. This searches for newlines immediately followed by another newline and replaces all occurences with a single newline, you may have to press this a few times until you get a message saying no occurences were found.
You may still see what appear to be blank lines as any spaces or tabs on a line will stop that line matching the above expression. The code for a tab is \t , so if (forsome strange reason) there is a tab on every blank line you would replace \n\t\n with \n
Learning how to use regular expressions can save you loads of time when working with text or data. Well worth looking into (even though it can be frustrating - keep backups until you are confident with it).