Util { public static boolean wildcardMatch(String text, String pattern) { if (pattern.length() > 0 && pattern.charAt(0) == '^') { return !wildcardMatch(text, pattern.substring(1)); } return text.matches(pattern.replace("?", ".?").replace("*", ".*?")); } private  Util(); static void sleep(long ms); static boolean wildcardMatch(String text, String pattern); static boolean isBlank(String s);  }
@Test public void testWildcardMatch() { assertFalse(Util.wildcardMatch("Test", "est")); assertTrue(Util.wildcardMatch("Test", "^est")); assertFalse(Util.wildcardMatch("Test", "^^est")); assertTrue(Util.wildcardMatch("Test", "?est")); assertFalse(Util.wildcardMatch("Test", "^?est")); assertTrue(Util.wildcardMatch("Test", "*est")); assertFalse(Util.wildcardMatch("Test", "^*est")); assertFalse(Util.wildcardMatch("Test", "T?t")); assertTrue(Util.wildcardMatch("Test", "T??t")); assertTrue(Util.wildcardMatch("Test", "T*t")); assertFalse(Util.wildcardMatch("Test", "Tes")); assertTrue(Util.wildcardMatch("Test", "Tes?")); assertTrue(Util.wildcardMatch("Test", "Tes*")); assertFalse(Util.wildcardMatch("Test", "Te?")); assertTrue(Util.wildcardMatch("Test", "Te*")); }