javascript - Control escape string -


i have function result each group. problem got error because of escape string. how control it. sampel e: o'neil

here script:

function specificname(e) {    var resulta;   var resultb;   var resultc;    console.log("name:"+ e);    (var = 0; < a.length; i++) {     if (a[i].nama_a == e) {      resulta=a[i];    }  }   (var = b.length - 1; >= 0; i--) {   if(b[i].nama_b == e){     resultb=b[i];   } }   (var = c.length - 1; >= 0; i--) {   if(c[i].nama_c ==e){     resultc=c[i];   } } 

i have try this.

var mystr2 = e.replace(/'/g, "''"); 

but same.

thank helping me.

you need escape quote, like:

var mystr2 = str.replace(/'/g, "\\'"); console.log(mystr2); // gives o\'neil 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -