Created
August 27, 2013 17:01
-
-
Save adriancooney/6356197 to your computer and use it in GitHub Desktop.
"Native" multiline Javascript strings (with some funky syntax)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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