Quote:
Sort of related - I have a bunch of stories which I want to use - but all the lines are double spaced
Is there a way of clearing all empty lines using php...
|
As an alternative, using regex in a text editor you can do this...
Search for: \r\r
Replace with: \r
Finds two carriage returns in a row and replaces them with one carriage return.
If I'm searching for *nix line feeds instead of carriage returns, I use \n instead of \r in the search and replace.
Again, I'm not sure which Windows editors do these kinds of searches, but BBEdit on the Mac lets you run these kinds of searches on a whole folder full of text files and process them as a batch right from the text editor.
If you don't need to preserve the order of the lines, one other option would be to sort the text file, which would put all the blank lines together so you can delete them. Then cleaned text file could be opened in Excel or other spreadsheet program where the lines can be sorted randomly again if you need to do that before importing to somewhere.