wildcard matcher: quote replacement to prevent the matcher from replacing group references
This commit is contained in:
@@ -45,7 +45,7 @@ public class WildcardMatcher
|
||||
}
|
||||
else
|
||||
{
|
||||
matcher.appendReplacement(buffer, "\\\\Q" + matcher.group(0) + "\\\\E");
|
||||
matcher.appendReplacement(buffer, Matcher.quoteReplacement(Pattern.quote(matcher.group(0))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,5 +39,6 @@ public class WildcardMatcherTest
|
||||
assertFalse(matches("Abyssal whip", "Adamant dagger"));
|
||||
assertTrue(matches("rune*", "Runeite Ore"));
|
||||
assertTrue(matches("Abyssal whip", "Abyssal whip"));
|
||||
assertTrue(matches("string $ with special character", "string $ with special character"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user