public static Pattern glob2Pattern(String... globs){
  final StringBuilder regex=new StringBuilder();
  boolean needOr=false;
  for (  String glob : globs) {
    if (needOr) {
      regex.append('|');
    }
    int i=0, len=glob.length();
    while (i < len) {
      char c=glob.charAt(i++);
switch (c) {
case '*':
        if (i < len && glob.charAt(i) == '*') {
          regex.append(".*");
          i++;
        }
 else {
          regex.append("[^.]*");
        }
      break;
case '?':
    regex.append("[^.]");
  break;
default :
if (isRegexMeta(c)) {
  regex.append('\\');
}
regex.append(c);
}
}
needOr=true;
}
return Pattern.compile(regex.toString(),0);
}

public static Pattern glob2Pattern ( String ... globs ) { final StringBuilder regex = new StringBuilder ( ) ; boolean needOr = false ; for ( String glob : globs ) { if ( needOr ) { regex . append ( '|' ) ; } int i = 0 , len = glob . length ( ) ; while ( i < len ) { char c = glob . charAt ( i ++ ) ; switch ( c ) { case '*' : if ( i < len && glob . charAt ( i ) == '*' ) { regex . append ( ".*" ) ; i ++ ; } else { regex . append ( "[^.]*" ) ; } break ; case '?' : regex . append ( "[^.]" ) ; break ; default : if ( isRegexMeta ( c ) ) { regex . append ( '\\' ) ; } regex . append ( c ) ; } } needOr = true ; } return Pattern . compile ( regex . toString ( ) , 0 ) ; }
returns a regex pattern that matches on any of the globs on class names ( e . g . , " sun . misc . * * " )
