public static int indexOfIgnoreCase(int startingPosition,String searchIn,String searchFor,String openingMarkers,String closingMarkers,Set<SearchMode> searchMode){
  if (searchIn == null || searchFor == null) {
    return -1;
  }
  int searchInLength=searchIn.length();
  int searchForLength=searchFor.length();
  int stopSearchingAt=searchInLength - searchForLength;
  if (startingPosition > stopSearchingAt || searchForLength == 0) {
    return -1;
  }
  if (searchMode.contains(SearchMode.SKIP_BETWEEN_MARKERS) && (openingMarkers == null || closingMarkers == null || openingMarkers.length() != closingMarkers.length())) {
    throw new IllegalArgumentException(Messages.getString("StringUtils.15",new String[]{openingMarkers,closingMarkers}));
  }
  char firstCharOfSearchForUc=Character.toUpperCase(searchFor.charAt(0));
  char firstCharOfSearchForLc=Character.toLowerCase(searchFor.charAt(0));
  if (Character.isWhitespace(firstCharOfSearchForLc) && searchMode.contains(SearchMode.SKIP_WHITE_SPACE)) {
    searchMode=EnumSet.copyOf(searchMode);
    searchMode.remove(SearchMode.SKIP_WHITE_SPACE);
  }
  for (int i=startingPosition; i <= stopSearchingAt; i++) {
    i=indexOfNextChar(i,stopSearchingAt,searchIn,openingMarkers,closingMarkers,searchMode);
    if (i == -1) {
      return -1;
    }
    char c=searchIn.charAt(i);
    if (isCharEqualIgnoreCase(c,firstCharOfSearchForUc,firstCharOfSearchForLc) && startsWithIgnoreCase(searchIn,i,searchFor)) {
      return i;
    }
  }
  return -1;
}

public static int indexOfIgnoreCase ( int startingPosition , String searchIn , String searchFor , String openingMarkers , String closingMarkers , Set < SearchMode > searchMode ) { if ( searchIn == null || searchFor == null ) { return - 1 ; } int searchInLength = searchIn . length ( ) ; int searchForLength = searchFor . length ( ) ; int stopSearchingAt = searchInLength - searchForLength ; if ( startingPosition > stopSearchingAt || searchForLength == 0 ) { return - 1 ; } if ( searchMode . contains ( SearchMode . SKIP_BETWEEN_MARKERS ) && ( openingMarkers == null || closingMarkers == null || openingMarkers . length ( ) != closingMarkers . length ( ) ) ) { throw new IllegalArgumentException ( Messages . getString ( "StringUtils.15" , new String [ ] { openingMarkers , closingMarkers } ) ) ; } char firstCharOfSearchForUc = Character . toUpperCase ( searchFor . charAt ( 0 ) ) ; char firstCharOfSearchForLc = Character . toLowerCase ( searchFor . charAt ( 0 ) ) ; if ( Character . isWhitespace ( firstCharOfSearchForLc ) && searchMode . contains ( SearchMode . SKIP_WHITE_SPACE ) ) { searchMode = EnumSet . copyOf ( searchMode ) ; searchMode . remove ( SearchMode . SKIP_WHITE_SPACE ) ; } for ( int i = startingPosition ; i <= stopSearchingAt ; i ++ ) { i = indexOfNextChar ( i , stopSearchingAt , searchIn , openingMarkers , closingMarkers , searchMode ) ; if ( i == - 1 ) { return - 1 ; } char c = searchIn . charAt ( i ) ; if ( isCharEqualIgnoreCase ( c , firstCharOfSearchForUc , firstCharOfSearchForLc ) && startsWithIgnoreCase ( searchIn , i , searchFor ) ) { return i ; } } return - 1 ; }
finds the position of a substring within a string , ignoring case , with the option to skip text delimited by given markers or within comments .
