  for (const [i, part] of string.split(color).entries()) {
    if (i % 2 === 0) {
      for (const char of part.split("")) {
        if (index >= start && index < end) {
          result += char;
        }
        index++;
      }
    } else if (
      start === 0 && end === 0
        ? false
        : start === 0
        ? index >= 0 && index <= end