2019-01-28 20:25:26 +08:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2018-07-02 18:01:01 +08:00
|
|
|
function replaceStrFormIndexArr(str, replaceStr, indexArr) {
|
|
|
|
let arr = [];
|
|
|
|
let result = "";
|
|
|
|
let index = 0;
|
|
|
|
if (!indexArr || indexArr.length < 1) {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
for (let i = 0; i < indexArr.length; i++) {
|
|
|
|
let indexItem = indexArr[i];
|
|
|
|
let begin = indexItem.begin;
|
|
|
|
result = result + str.substring(index, begin) + replaceStr;
|
|
|
|
index = indexItem.end + 1;
|
|
|
|
if (i == indexArr.length - 1) {
|
|
|
|
result = result + str.substring(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2019-01-28 20:25:26 +08:00
|
|
|
exports.replaceStrFormIndexArr = replaceStrFormIndexArr;
|