private void initializePattern ( final String pattern ) { final String [ ] split = pattern . split ( Pattern . quote ( "*" ) , - 1 ) ; final StringBuilder escapedPattern = new StringBuilder ( Pattern . quote ( split [ 0 ] ) ) ; for ( int i = 1 ; i < split . length ; i ++ ) { String quoted = Pattern . quote ( split [ i ] ) ; escapedPattern . append ( "([^.]*)" ) . append ( quoted ) ; } final String regex = "^" + escapedPattern . toString ( ) + "$" ; this . patternStr = regex ; this . pattern = Pattern . compile ( regex ) ; }
Turns the GLOB pattern into a REGEX .