public static int indexOfIgnoreCase ( String pString , int pChar , int pPos ) { if ( ( pString == null ) ) { return - 1 ; } // Get first char char lower = Character . toLowerCase ( ( char ) pChar ) ; char upper = Character . toUpperCase ( ( char ) pChar ) ; int indexLower ; int indexUpper ; // Test for char indexLower = pString . indexOf ( lower , pPos ) ; indexUpper = pString . indexOf ( upper , pPos ) ; if ( indexLower < 0 ) { /* if (indexUpper < 0) return -1; // First char not found else */ return indexUpper ; // Only upper } else if ( indexUpper < 0 ) { return indexLower ; // Only lower } else { // Both found, select first occurence return ( indexLower < indexUpper ) ? indexLower : indexUpper ; } }
Returns the index within this string of the first occurrence of the specified character starting at the specified index .