private static String extractShortcut(String pattern){
  char[] wildcardChars=new char[]{'*','?'};
  int startIndex=0;
  int endIndex=StringUtils.indexOfAny(pattern,wildcardChars);
  if (endIndex < 0) {
    return pattern;
  }
  String shortcut=endIndex == startIndex ? StringUtils.EMPTY : pattern.substring(startIndex,endIndex - startIndex);
  while (endIndex >= 0) {
    startIndex=startIndex + endIndex + 1;
    if (pattern.length() <= startIndex) {
      break;
    }
    endIndex=StringUtils.indexOfAny(pattern.substring(startIndex),wildcardChars);
    String tmpShortcut=endIndex < 0 ? pattern.substring(startIndex) : pattern.substring(startIndex,endIndex + startIndex);
    if (tmpShortcut.length() > shortcut.length()) {
      shortcut=tmpShortcut;
    }
  }
  return shortcut;
}

private static String extractShortcut ( String pattern ) { char [ ] wildcardChars = new char [ ] { '*' , '?' } ; int startIndex = 0 ; int endIndex = StringUtils . indexOfAny ( pattern , wildcardChars ) ; if ( endIndex < 0 ) { return pattern ; } String shortcut = endIndex == startIndex ? StringUtils . EMPTY : pattern . substring ( startIndex , endIndex - startIndex ) ; while ( endIndex >= 0 ) { startIndex = startIndex + endIndex + 1 ; if ( pattern . length ( ) <= startIndex ) { break ; } endIndex = StringUtils . indexOfAny ( pattern . substring ( startIndex ) , wildcardChars ) ; String tmpShortcut = endIndex < 0 ? pattern . substring ( startIndex ) : pattern . substring ( startIndex , endIndex + startIndex ) ; if ( tmpShortcut . length ( ) > shortcut . length ( ) ) { shortcut = tmpShortcut ; } } return shortcut ; }
extracts longest string that does not contain * or ? symbols .
