jquery / JavaScript replace xth occurance -
i have string :
var str = "a a";
how replace specific else ?
eg: replace 3rd :
var str = "a 00 a";
of 1st, 2nd, etc.. ?
thanks
i split str, replace whatever index, join back
var str = "a a"; var sp=str.split(' '); var ind=2; sp[ind]='00'; console.log(sp.join(' '));
Comments
Post a Comment