String output = "";
pattern = Pattern.compile(">Part\s.");
matcher = pattern.matcher(docToProcess);
while (matcher.find()) {
match = matcher.group();
}
我正在尝试使用上面的代码来查找>Part\s.
里面的模式docToProcess
(这是一个大型 xml 文档的字符串),然后我想要做的是将与模式匹配的内容替换为<ref></ref>
有什么想法可以使output
变量等于docToProcess
除了上面指出的替换吗?
编辑:更换时我需要以某种方式使用匹配器。我不能只使用replaceAll()