UNPKG

diginext-utils

Version:
15 lines (14 loc) 436 B
import indexesOf from "./indexesOf"; export default function getTextBetweenCharByIndex(str, char, index) { const arr = indexesOf(str, char); let start = 0, end = 0; for (let i = 0; i < arr.length; i++) { const _index = arr[i]; if (index > _index) { start = _index; end = arr[i + 1]; } } const result = str.substring(start + 1, end); return result; }