WildcardMatcher { public static boolean matches(String pattern, String text) { final Matcher matcher = WILDCARD_PATTERN.matcher(pattern); final StringBuffer buffer = new StringBuffer(); buffer.append("(?i)"); while (matcher.find()) { if (matcher.group(1) != null) { matcher.appendReplacement(buffer, ".*"); } else { matcher.appendReplacement(buffer, "\\\\Q" + matcher.group(0) + "\\\\E"); } } matcher.appendTail(buffer); final String replaced = buffer.toString(); return text.matches(replaced); }  static boolean matches(String pattern, String text);  }
@Test public void testMatches() { assertTrue(matches("rune*", "rune pouch")); assertTrue(matches("rune*", "Rune pouch")); assertFalse(matches("Abyssal whip", "Adamant dagger")); assertTrue(matches("rune*", "Runeite Ore")); assertTrue(matches("Abyssal whip", "Abyssal whip")); }