Posted By

sarfraznawaz2005 on 03/24/09


Tagged

addslashes slash stripslashes


Versions (?)

Addslahes, Stripslashes


 / Published in: JavaScript
 

  1. function addslashes(str) {
  2. str=str.replace(/\'/g,'\\\'');
  3. str=str.replace(/\"/g,'\\"');
  4. str=str.replace(/\\/g,'\\\\');
  5. str=str.replace(/\0/g,'\\0');
  6. return str;
  7. }
  8.  
  9. function stripslashes(str) {
  10. str=str.replace(/\\'/g,'\'');
  11. str=str.replace(/\\"/g,'"');
  12. str=str.replace(/\\\\/g,'\\');
  13. str=str.replace(/\\0/g,'\0');
  14. return str;
  15. }

Report this snippet  

You need to login to post a comment.