private static int indexOfIgnoreCase(CharSequence source, int sourceOffset, int sourceCount,
                                       CharSequence target, int targetOffset, int targetCount,
                                       int fromIndex) {
    if (fromIndex >= sourceCount) {
      return (targetCount == 0 ? sourceCount : -1);
    }
    if (fromIndex < 0) {
      fromIndex = 0;
    }
    if (targetCount == 0) {
      return fromIndex;
    }

    char first = target.charAt(targetOffset);
    int firstAlphaIndex = getAlphaIndex(first);
    int max = sourceOffset + (sourceCount - targetCount);

    for (int i = sourceOffset + fromIndex; i <= max; i++) {
      /* Look for first character. */
      while (i <= max) {
        char sourceI = source.charAt(i);
        if (sourceI == first) {
          break;
        }
        int sourceIAlphaIndex = getAlphaIndex(sourceI);
        if (sourceIAlphaIndex >= 26 || sourceIAlphaIndex != firstAlphaIndex) {
          ++i;
          continue;
        }
        break;
      }

      /* Found first character, now look at the rest of v2 */
      if (i <= max) {
        int j = i + 1;
        int end = j + targetCount - 1;
        char sourceJ;
        int sourceJAlphaIndex;
        char targetK;
        for (int k = targetOffset + 1; j < end; j++, k++) {
          sourceJ = source.charAt(j);
          targetK = target.charAt(k);
          if (sourceJ == targetK) {
            continue;
          }
          sourceJAlphaIndex = getAlphaIndex(sourceJ);
          if (sourceJAlphaIndex < 26 && sourceJAlphaIndex == getAlphaIndex(targetK)) {
            continue;
          }
          break;
        }

        if (j == end) {
          /* Found whole string. */
          return i - sourceOffset;
        }
      }
    }
    return -1;
  }
private static int indexOfIgnoreCase ( CharSequence source , int sourceOffset , int sourceCount , CharSequence target , int targetOffset , int targetCount , int fromIndex ) { if ( fromIndex >= sourceCount ) { return ( targetCount == 0 ? sourceCount : - 1 ) ; } if ( fromIndex < 0 ) { fromIndex = 0 ; } if ( targetCount == 0 ) { return fromIndex ; } char first = target . charAt ( targetOffset ) ; int firstAlphaIndex = getAlphaIndex ( first ) ; int max = sourceOffset + ( sourceCount - targetCount ) ; for ( int i = sourceOffset + fromIndex ; i <= max ; i ++ ) { while ( i <= max ) { char sourceI = source . charAt ( i ) ; if ( sourceI == first ) { break ; } int sourceIAlphaIndex = getAlphaIndex ( sourceI ) ; if ( sourceIAlphaIndex >= 26 || sourceIAlphaIndex != firstAlphaIndex ) { ++ i ; continue ; } break ; } if ( i <= max ) { int j = i + 1 ; int end = j + targetCount - 1 ; char sourceJ ; int sourceJAlphaIndex ; char targetK ; for ( int k = targetOffset + 1 ; j < end ; j ++ , k ++ ) { sourceJ = source . charAt ( j ) ; targetK = target . charAt ( k ) ; if ( sourceJ == targetK ) { continue ; } sourceJAlphaIndex = getAlphaIndex ( sourceJ ) ; if ( sourceJAlphaIndex < 26 && sourceJAlphaIndex == getAlphaIndex ( targetK ) ) { continue ; } break ; } if ( j == end ) { return i - sourceOffset ; } } } return - 1 ; }
Searches through {@code source} to find {@code target}, ignoring the case of
any ASCII alphabetic characters between {@code 'a'} and {@code 'z'}
or {@code 'A'} and {@code 'Z'} inclusive.

@param source       the characters being searched.
@param sourceOffset offset of the source string.
@param sourceCount  count of the source string.
@param target       the characters being searched for.
@param targetOffset offset of the target string.
@param targetCount  count of the target string.
@param fromIndex    the index to begin searching from.