/** * Splits a string into 3 parts for text highlighting * @param {string} textToSearchIn * @param {string} searchStr * @returns {str[]} */ export const splitStringForHighlight = (textToSearchIn: string, searchStr: string) => { const str = String(searchStr).trim(); const text = String(textToSearchIn).trim(); const index = text.indexOf(str); if (index >= 0) { const part1 = text.substring(0, index); const part2 = text.substring(index, index + str.length); const part3 = text.substring(index + str.length); return [part1, part2, part3]; } else { return [text]; } };