Methods Summary |
---|
public static java.util.regex.Pattern[] | exprsToPatterns(java.lang.String[] exprs)Converts each String to a Pattern using wildcardToJavaRegex
return( exprsToPatterns( exprs, 0 ) );
|
public static java.util.regex.Pattern[] | exprsToPatterns(java.lang.String[] exprs, int flags)Converts each String to a Pattern using wildcardToJavaRegex, passing the flags.
final Pattern[] patterns = new Pattern[ exprs.length ];
for( int i = 0; i < exprs.length; ++i )
{
patterns[ i ] = Pattern.compile( wildcardToJavaRegex( exprs[ i ]), flags );
}
return( patterns );
|
public static java.lang.String | wildcardToJavaRegex(java.lang.String input)Supports the single wildcard "*". There is no support for searching for
a literal "*".
Convert a string to a form suitable for passing to java.util.regex.
String converted = input;
if ( input != null )
{
final int length = input.length();
final StringBuffer buf = new StringBuffer();
for( int i = 0; i < length; ++i )
{
final char theChar = input.charAt( i );
if ( theChar == '." )
{
buf.append( "[.]" );
}
else if ( theChar == '*" )
{
buf.append( ".*" );
}
else if ( REGEX_SPECIALS.indexOf( theChar ) >= 0 )
{
// '[' begins a set of characters
buf.append( "" + BACKSLASH + theChar );
}
else
{
buf.append( theChar );
}
}
converted = buf.toString();
}
return( converted );
|