Skip to content

Instantly share code, notes, and snippets.

@adriancooney
Created August 27, 2013 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adriancooney/6356197 to your computer and use it in GitHub Desktop.
Save adriancooney/6356197 to your computer and use it in GitHub Desktop.
"Native" multiline Javascript strings (with some funky syntax)
var multiline = function(string) {
// Replace the "function() {/*\n" and "\n*/}" with nothing and bam, multiline strings
return string.toString().replace(/(^[^\n]*\n)|(\n\*\/\})/g, "");
};
console.log(multiline(function() {/*
Hello world!
I'm a multiline string!
Tada!
*/}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment