Permalink
Browse files

0003708: Wildcard does not work when there is no wildcard at the

beginning or the end of the text
  • Loading branch information...
philipmarzullo64 committed Feb 6, 2019
1 parent 886645a commit af86a1cc2b2ef96d31554c7e386614d717ee52a9
@@ -196,10 +196,13 @@ public static boolean isWildCardMatch(String text, String pattern) {
String card = cards[i];

boolean foundToken = false;
if (i == 0 && !pattern.startsWith("*") && pattern.endsWith("*")) {

if (! pattern.contains("*")) {
foundToken = text.equals(card);
} else if (i == 0 && !pattern.startsWith("*") && pattern.endsWith("*")) {
foundToken = text.startsWith(card);
} else if (i == 0 && !pattern.startsWith("*")) {
foundToken = text.equals(card);
foundToken = text.startsWith(card);
} else {
foundToken = text.indexOf(card) != -1;
}
@@ -215,7 +218,7 @@ public static boolean isWildCardMatch(String text, String pattern) {

return match;
}

/**
* Word wrap a string where the line size for the first line is different
* than the lines sizes for the other lines.
@@ -70,5 +70,6 @@ public void testIsWildcardMatch() {
assertFalse(FormatUtils.isWildCardMatch("B_A", "*A*B"));
assertTrue(FormatUtils.isWildCardMatch("A_B", "*A*B"));
assertFalse(FormatUtils.isWildCardMatch("TEST_NO_MATCH", "TEST_*,!TEST_NO_MATCH"));
assertTrue(FormatUtils.isWildCardMatch("A_B", "A*B"));
}
}

0 comments on commit af86a1c

Please sign in to comment.