public class WildcardUtils extends Object
Constructor and Description |
---|
WildcardUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
wildcardMatch(String content,
String wildcardMatcher)
Checks a filename to see if it matches the specified wildcard matcher,
always testing case-sensitive.
|
static boolean |
wildcardMatch(String content,
String wildcardMatcher,
boolean caseSensitivity)
Checks a filename to see if it matches the specified wildcard matcher
allowing control over case-sensitivity.
|
public static boolean wildcardMatch(String content, String wildcardMatcher)
The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. This is the same as often found on Dos/Unix command lines. The check is case-sensitive always.
wildcardMatch("c.txt", "*.txt") -- true wildcardMatch("c.txt", "*.jpg") -- false wildcardMatch("a/b/c.txt", "a/b/*") -- true wildcardMatch("c.txt", "*.???") -- true wildcardMatch("c.txt", "*.????") -- falseN.B. the sequence "*?" does not work properly at present in match strings.
content
- the content to match onwildcardMatcher
- the wildcard string to match againstpublic static boolean wildcardMatch(String content, String wildcardMatcher, boolean caseSensitivity)
The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. N.B. the sequence "*?" does not work properly at present in match strings.
content
- the filename to match onwildcardMatcher
- the wildcard string to match againstcaseSensitivity
- what case sensitivity rule to use, null means case-sensitiveCopyright © 2018 Guangshan Technology, Inc.. All rights reserved.