假设我有一个如下所示的链接以及一堆其他链接
http://testttt.com/met?tag1=x&tag2=y&tag3=z%20a
我想提取以 http://testttt.com/met 开头的整个链接。
我尝试执行以下操作,但没有成功
Pattern pattern = Pattern.compile("http://testttt.com/met?[a-zA-Z][0-9]");
Matcher match = pattern.matcher("http://testttt.com/met?tag1=x&tag2=y&tag3=z%20a");
if (match.find()) {
System.out.println("match found");
}
最佳答案
为什么不直接使用
if (str.startsWith("http://testttt.com/met")) {
...
}
关于java - 使用java模式匹配器提取特定的链接模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17372640/