Javascript String escapeQuotes()

Description

Javascript String escapeQuotes()

String.prototype.escapeQuotes = function()
{
  var m = {"\"": "\\\"", "'": "\\'"};

  return String(this.replace("\\", "\\\\")).replace(/["']/g, function(s)
  {//from w w w .  j ava 2 s. c o  m
    return m[s];
  });
}



PreviousNext

Related