Represents a string pattern that may optionally include wildcards ('*', '**' or '?'), and provides an API to determine whether that pattern matches a specified input string.
The wildcard character '*' within the pattern matches a sequence of zero or more characters within a single file or directory name in the input string. It does not match a sequence of two or more dir/file names. For instance, 'a*b' matches 'a12345b' and 'ab', but does NOT match 'a/b' or 'a123/b'. The '**' wildcard matches any sequence of zero or more characters in the input string, including directory names and separators . It matches any part of the directory tree. For instance, 'a**b' matches 'a12345b', 'ab', 'a/b' and 'a1/a2/a3b'. The wildcard character '?' within the pattern matches exactly one character in the input string, excluding the normalized file separator character ('/'). This is an internal class and its API is subject to change.Constructor and description |
---|
WildcardPattern
(String patternString, boolean defaultMatches = true) Construct a new WildcardPattern instance on a single pattern or a comma-separated list of patterns. |
Construct a new WildcardPattern instance on a single pattern or a comma-separated list of patterns.
patternString
- - the pattern string, optionally including wildcard characters ('*' or '?');
may optionally contain more than one pattern, separated by commas; may be null or empty to always matchdefaultMatches
- - a boolean indicating whether matches()
should
return true if the pattern string is either empty or null. This parameter is
optional and defaults to true
.Return true if the specified String matches the pattern or if the original patternString (specified in the constructor) was null or empty and the value for defaultMatches (also specified in the constructor) was true.
string
- - the String to check