Android Patterns.WEB_URL坏了吗?

时间:2016-04-12 23:58:43

标签: android regex

那么,有人可以在我的测试中解释尾部斜线发生了什么变化吗?或者它是WEB_URL模式的错误?

@Test
public void testWebUrl() {
    String url = "http://www.google.com/foo/";
    String test = "A string that fails is this: " + url + " <-- see that?";

    Matcher m = Patterns.WEB_URL.matcher(test);
    while (m.find()) {
        assertTrue(Patterns.WEB_URL.matcher(url).matches());  // PASSES
        assertEquals(m.group(), url);  // FAILS
        // Here, m.group() == "http://www.google.com/foo", without the trailing "/"
    }
}

0 个答案:

没有答案