js在字符串的指定位置插入新的字符
方法一:
var str = 'aaa_bbb';
var reg = /_/g;
var insertStr = "ccc_"
console.log(str.replace(reg,"_"+insertStr))//aaa_ccc_bbb
方法二:
String.prototype.splice = function(start, newStr) {
return this.slice(0, start) + newStr + this.slice(start);
};
var index = 'aaa_bbb'.indexOf('_');
var str = 'aaa_bbb'.splice(index+1, 'ccc_');