Skip to content

Instantly share code, notes, and snippets.

@raspo
Created March 11, 2012 12:32
Show Gist options
  • Save raspo/2016270 to your computer and use it in GitHub Desktop.
Save raspo/2016270 to your computer and use it in GitHub Desktop.
Addslashes function for javascript
function addslashes(str) {
str=str.replace(/\\/g,'\\\\');
//str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\0/g,'\\0');
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment