【发布时间】:2014-12-17 08:48:56
【问题描述】:
我写了一个单元测试来帮助我理解 Pattern.quote 并且我一生都无法弄清楚为什么这个测试没有通过。
@Test
public void testRegexEscape() throws Exception {
String text = "Test";
String patternString = "es";
String quoted = Pattern.quote(patternString);
Pattern pattern = Pattern.compile(quoted);
Matcher matcher = pattern.matcher(text);
assertTrue(matcher.matches());
}
【问题讨论】: