question: public static int wildCompare ( String searchIn , String searchForWildcard ) { if ( ( searchIn == null ) || ( searchForWildcard == null ) ) { return WILD_COMPARE_NO_MATCH ; } if ( searchForWildcard . equals ( "%" ) ) { return WILD_COMPARE_MATCH_WITH_WILD ; } int result = WILD_COMPARE_NO_MATCH ; char wildcardMany = '%' ; char wildcardOne = '_' ; char wildcardEscape = '\\' ; int searchForPos = 0 ; int searchForEnd = searchForWildcard . length ( ) ; int searchInPos = 0 ; int searchInEnd = searchIn . length ( ) ; while ( searchForPos != searchForEnd ) { char wildstrChar = searchForWildcard . charAt ( searchForPos ) ; while ( ( searchForWildcard . charAt ( searchForPos ) != wildcardMany ) && ( wildstrChar != wildcardOne ) ) { if ( ( searchForWildcard . charAt ( searchForPos ) == wildcardEscape ) && ( ( searchForPos + 1 ) != searchForEnd ) ) { searchForPos ++ ; } if ( ( searchInPos == searchInEnd ) || ( Character . toUpperCase ( searchForWildcard . charAt ( searchForPos ++ ) ) != Character . toUpperCase ( searchIn . charAt ( searchInPos ++ ) ) ) ) { return WILD_COMPARE_MATCH_WITH_WILD ; } if ( searchForPos == searchForEnd ) { return ( ( searchInPos != searchInEnd ) ? WILD_COMPARE_MATCH_WITH_WILD : WILD_COMPARE_MATCH_NO_WILD ) ; } result = WILD_COMPARE_MATCH_WITH_WILD ; } if ( searchForWildcard . charAt ( searchForPos ) == wildcardOne ) { do { if ( searchInPos == searchInEnd ) { return ( result ) ; } searchInPos ++ ; } while ( ( ++ searchForPos < searchForEnd ) && ( searchForWildcard . charAt ( searchForPos ) == wildcardOne ) ) ; if ( searchForPos == searchForEnd ) { break ; } } if ( searchForWildcard . charAt ( searchForPos ) == wildcardMany ) { char cmp ; searchForPos ++ ; for ( ; searchForPos != searchForEnd ; searchForPos ++ ) { if ( searchForWildcard . charAt ( searchForPos ) == wildcardMany ) { continue ; } if ( searchForWildcard . charAt ( searchForPos ) == wildcardOne ) { if ( searchInPos == searchInEnd ) { return ( WILD_COMPARE_NO_MATCH ) ; } searchInPos ++ ; continue ; } break ; } if ( searchForPos == searchForEnd ) { return WILD_COMPARE_MATCH_NO_WILD ; } if ( searchInPos == searchInEnd ) { return WILD_COMPARE_NO_MATCH ; } if ( ( ( cmp = searchForWildcard . charAt ( searchForPos ) ) == wildcardEscape ) && ( ( searchForPos + 1 ) != searchForEnd ) ) { cmp = searchForWildcard . charAt ( ++ searchForPos ) ; } searchForPos ++ ; do { while ( ( searchInPos != searchInEnd ) && ( Character . toUpperCase ( searchIn . charAt ( searchInPos ) ) != Character . toUpperCase ( cmp ) ) ) { searchInPos ++ ; } if ( searchInPos ++ == searchInEnd ) { return WILD_COMPARE_NO_MATCH ; } { int tmp = wildCompare ( searchIn , searchForWildcard ) ; if ( tmp <= 0 ) { return ( tmp ) ; } } } while ( ( searchInPos != searchInEnd ) && ( searchForWildcard . charAt ( 0 ) != wildcardMany ) ) ; return WILD_COMPARE_NO_MATCH ; } } return ( ( searchInPos != searchInEnd ) ? WILD_COMPARE_MATCH_WITH_WILD : WILD_COMPARE_MATCH_NO_WILD ) ; }
target:  Compares searchIn against searchForWildcard with wildcards (heavily borrowed from strings/ctype-simple.c in the server sources)