Skip to content

Instantly share code, notes, and snippets.

@dafi
Created August 6, 2010 14:24
Show Gist options
  • Save dafi/511384 to your computer and use it in GitHub Desktop.
Save dafi/511384 to your computer and use it in GitHub Desktop.
// remove empty lines and multiple carriage return/newline
var lines = "1\r\n\n\n\n2\n3\n\n \n\n"
.replace(/^\s*$/mg, '') // remove empty lines
.replace(/[\r\n]+/g, '\n') // all carriage return/newline
.replace(/\n$/, '') // remove newline at end
.split('\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment