我需要计算正则表达式找到声明数组的匹配项。我试过了,.groupCount()
但这似乎不是正确的事情^^我的代码:
Pattern p2 = Pattern.compile("<char>(.*?)</char>");
response = response.replaceAll("[\\r\\n]+", "");
Matcher m2 = p2.matcher(response);
String[] chars = new String[m2.groupCount()];
它应该找到 2,但说 1。有人可以帮忙吗?