Monday, 2 June 2014

JQuery Replace last occurence of character in string

var str="Hello_Welcome_to_jquery";
var pos = str.lastIndexOf('_');
str = str.substring(0,pos) + "_My"+ str.substring(pos+1)

O/P: "Hello_Welcome_to_Myjquery"