List of utility methods to do Wildcard Match
boolean | wildCardMatch(final String needle, final String haystack) Checks to see if needle matches haystack, where needle uses special characters known as wildcards. char[] wildcard = needle.toCharArray(), string = haystack.toCharArray(); int str = 0, wil = 0; for (; wil < wildcard.length; wil++) { char wild = wildcard[wil]; if (wild == '\\') { wil++; if (wildcard[wil] != string[str]) return false; ... |
boolean | wildcardMatch(final String pattern, final int patternIndex, final String value, final int valueIndex) Performs a match operation using wildcards. int tmpPatternIndex = patternIndex; int tmpValueIndex = valueIndex; while (tmpPatternIndex < pattern.length()) { if (SINGLE_TOKEN == pattern.charAt(tmpPatternIndex)) { tmpPatternIndex += 1; if (tmpValueIndex < value.length()) { tmpValueIndex += 1; } else { ... |
boolean | wildcardMatch(final String text, final String wildcard) Return true if text matches with entered wildcard pattern. if (text == null && wildcard == null) return true; String wildcardRegex = wildcard; if (wildcard != null) { wildcardRegex = wildcardRegex.replaceAll(ANY_SYMBOL, ANY_SYMBOL_REGEXP_REPLACEMENT); wildcardRegex = wildcardRegex.replaceAll(ANY_DOT_SYMBOLS, ANY_DOT_SYMBOL_REGEXP_REPLACEMENT); wildcardRegex = wildcardRegex.replaceAll(ANY_SYMBOLS_SET, ANY_SYMBOLS_SET_REGEXP_REPLACEMENT); return regexMatch(text, wildcardRegex); |
boolean | wildcardMatch(String input, String pattern) Tries to match input with pattern. String regex = pattern.replace("?", ".?").replace("*", ".*?"); return input.matches(regex); |
boolean | wildcardMatch(String pattern, String name) Match pattern against name, where pattern may contain wildcards ('*'). return wildcardMatch(pattern, name, 0, 0, pattern.length(), name.length());
|
boolean | wildcardMatch(String pattern, String string) wildcard Match int stringLength = string.length(); int stringIndex = 0; for (int patternIndex = 0; patternIndex < pattern.length(); ++patternIndex) { char c = pattern.charAt(patternIndex); if (c == '*') { while (stringIndex < stringLength) { if (wildcardMatch(pattern.substring(patternIndex + 1), string.substring(stringIndex))) { return true; ... |
boolean | wildcardMatch(String string, String pattern) wildcard Match int i = 0; int j = 0; int starIndex = -1; int iIndex = -1; while (i < string.length()) { if (j < pattern.length() && (pattern.charAt(j) == '?' || pattern.charAt(j) == string.charAt(i))) { ++i; ++j; ... |
boolean | wildCardMatch(String text, String pattern) Performs a wildcard comparison between two strings, where pattern contains the string with wildcards and text String[] cards = pattern.split("\\*");
for (String card : cards) {
int idx = text.indexOf(card);
if (idx == -1) {
return false;
text = text.substring(idx + card.length());
return true;
|
boolean | wildCardMatch(String text, String pattern) Returns if the given text matches the given search expression. if (pattern == null || pattern.length() == 0) { return true; if (pattern.length() == 1 && pattern.charAt(0) == '*') { return true; if (text == null || text.length() == 0) { return false; ... |
boolean | wildCardMatch(String text, String pattern) wild Card Match String[] cards = pattern.split("\\*"); for (int i = 0; i < cards.length; i++) { System.out.println(cards[i]); for (String card : cards) { int idx = text.indexOf(card); if (idx == -1) { return false; ... |