lava-oushudb-dt-sql-parser/lib/utils/index.js
2019-01-28 20:25:26 +08:00

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;