当存在未知数量的空格时,使用java替代正向查找
我的replacerRegex
是
("schedulingCancelModal": \{\s*? "title": ")(.+?)(?=")
但是,我如何使("schedulingCancelModal": \{\s*? "title": ")
不被包括在结果中,就像正向查找一样
到目前为止,我的Java代码:
Pattern replacerPattern = Pattern.compile(replacerRegex);
Matcher matcher = replacerPattern.matcher(value);
while (matcher.find()) {
String valueToBePicked = matcher.group();
}
# 1 楼答案
您只需选择
matcher.group(2)
即可获得第二个捕获组的内容。例如:输出:
Demo on rextester