Created
January 1, 2016 04:13
-
-
Save JavaScript-Packer/9d7444b87260d7c626c4 to your computer and use it in GitHub Desktop.
Simple and effective escaper function for JavaScript new lines, quotes, etc
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
function kleen(e, r) { | |
r = "replace"; | |
return e[r](/\\/g, "\\\\")[r](/\r/gm, "\n")[r](/\n{2,}/gm, "\n")[r](/\n/g, "\\n")[r](/\'/g, "\\'"[r](/\"/g, '\\"')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment