JavaScript stripslashes Writer #1, 2010-06-19 Sometimes you have to add slashes to javascript text. PHP has it built in, javascript does not. Here is the code to put into your javascript to get the same functionality: function addslashes(str) { str=str.replace(/\\\\/g,'\\\\\\\\'); str=str.replace(/\\'/g,'\\\\\\''); str=str.replace(/\\"/g,'\\\\"'); str=str.replace(/\\0/g,'\\\\0'); return str; } function stripslashes(str) { str=str.replace(/\\\\'/g,'\\''); str=str.replace(/\\\\"/g,'"'); str=str.replace(/\\\\0/g,'\\0'); str=str.replace(/\\\\\\\\/g,'\\\\'); return str; } Programming javascriptstripslashes