private static int nthIndexOf(@NotNull @NonNls String text, char c, int n) {
    assert n > 0;
    int length = text.length();
    int count = 0;
    for (int i = 0; i < length; i++) {
      if (text.charAt(i) == c) {
        count++;
        if (count == n) return i;
      }
    }
    return -1;
  }
private static int nthIndexOf(@NotNull @NonNls String text, char c, int n)