22 lines
677 B
JavaScript
22 lines
677 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
}
|
|
exports.replaceStrFormIndexArr = replaceStrFormIndexArr;
|