String escaping function - Node.js String

Node.js examples for String:Escape

Description

String escaping function

Demo Code


/**/*from   w ww  . ja  va2 s.c o m*/
 * Poor man's escaping function
 */
Utils.escapeStr = function(str) {
  str = str.replace(/</g, "&lt;");
  str = str.replace(/>/g, "&gt;")
  return str;
}

Related Tutorials