我正在尝试计算任何给定Java字符串中的URL数量:
String test = "Hello World!";
String urlRegex = "<\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]>";
pattern = Pattern.compile(urlRegex);
matcher = pattern.matcher(test);
numUrls = matcher.groupCount();
System.err.println("numUrls = " + numUrls);
我很惊讶numUrls
不是零。任何想法为什么?提前谢谢!
答案 0 :(得分:0)