📅  最后修改于: 2022-03-11 15:02:02.340000             🧑  作者: Mango
const string = "XYZ 123 ABC 456 ABC 789 ABC";
function getPosition(string, subString, index) {
return string.split(subString, index).join(subString).length;
}
console.log(
getPosition(string, 'ABC', 2) // --> 16
)