标签:style blog color os ar sp div log ad
js替换最后一次出现的匹配的字符串
var v = "abbbabbbbab"; var pos = v.lastIndexOf("a"); var vv = v.substring(0, pos) + "c" + v.substring(pos+1, v.length); alert(vv);
js直接替换第一次出现的匹配字符串
var str = "adksdjfldjfoeoxl"; var t = str.lastIndexOf("d"); str = str.replace(/d/, "c"); alert(str);
标签:style blog color os ar sp div log ad
原文地址:http://www.cnblogs.com/snowbaby-kang/p/4029141.html