public static int indexOfIgnoreCase ( final String str , final String searchStr ) { // NOSONAR if ( searchStr . isEmpty ( ) || str . isEmpty ( ) ) { return str . indexOf ( searchStr ) ; } for ( int i = 0 ; i < str . length ( ) ; ++ i ) { if ( i + searchStr . length ( ) > str . length ( ) ) { return - 1 ; } int j = 0 ; int ii = i ; while ( ii < str . length ( ) && j < searchStr . length ( ) ) { char c = Character . toLowerCase ( str . charAt ( ii ) ) ; char c2 = Character . toLowerCase ( searchStr . charAt ( j ) ) ; if ( c != c2 ) { break ; } j ++ ; ii ++ ; } if ( j == searchStr . length ( ) ) { return i ; } } return - 1 ; }
Return first postion ignore case return - 1 if not found