this community has helped me a lot with my work so i decide join to. i have this code :
var empnfill = ["á","é","í","ó","ú","&"]; //what i want to replace
var empnfill2 = ["á","é","í","ó","ú","&"]; // for what i want to replace
var empn;
for(i=0 ; i<empnfill.length; i++)
empn = new RegExp(empnfill[i], "g");
if(job.source_empname.indexOf(empnfill[i])>-1){
job.source_empname = job.source_empname.replace(empn,empnfill2[i]);
}
job.source_empname is just an object i have in my plataform and contains all the informacion. the problem is im trying to replace all occurrences and isn't working, I used to use this code:
var empnfill = [];
var empnfill2 = [];
for(i=0 ; i<empnfill.length; i++)
if(job.source_empname.indexOf(empnfill[i])>-1){
job.source_empname = job.source_empname.replace(empnfill[i],empnfill2[i]);
}
it work fine but just replace the first ocurrence
I thank you in advance to anyone who can help me