private static String globToRegex ( String glob ) { if ( glob . charAt ( 0 ) == ' ' || glob . contains ( "/" ) || glob . contains ( "~" ) ) { throw new IllegalArgumentException ( "Invalid character in file glob" ) ; } // treat dot as a literal. glob = glob . replace ( "." , "\\." ) ; glob = glob . replace ( "*" , ".+" ) ; glob = glob . replace ( "?" , ".{1}+" ) ; return glob ; }
Convert a limited file glob into a simple regex .