Node.js examples for String:Char
Map Strings To Other Strings, If Not Defined, Do Not Touch Characters
String.prototype.escape=function(map){ var output=""; var keys=Object.keys(map); var s=0;// w ww. jav a 2 s. c om while(true){ var min=this.length; var kk; for(var k=0;k<keys.length;k++){ var m=this.indexOf(keys[k], s); if (m>=0 && m<min){ min=m; kk=keys[k]; }//endif }//for output+=this.substring(s, min); if (min==this.length) return output; output+=map[kk]; s=min+kk.length; }//while };//method