Java Matcher find()指定一个特定的重复模式
以下是我的数据:Java Matcher find()指定一个特定的重复模式,java,regex,Java,Regex,以下是我的数据: '%%case.r_object_id%%' and application_phase = '%%case.status%%' and rp.quality = '%%case.<reno_application_person>.<child>.quality%% 如果在自定义类之后使用不情愿的量词,则解析器应该在下一次出现双精度%%时匹配,而不是遍历整个字符串:“(%[^\”\n]+?%%”)” 注意+后面的问号 还要记住: matcher.
'%%case.r_object_id%%' and application_phase = '%%case.status%%' and rp.quality = '%%case.<reno_application_person>.<child>.quality%%
如果在自定义类之后使用不情愿的量词,则解析器应该在下一次出现双精度
%%
时匹配,而不是遍历整个字符串:“(%[^\”\n]+?%%”)”
注意+
后面的问号
还要记住:
matcher.appendTail(stringbuffer)
一旦你完成了
文档
case.r_object_id
case.status
case.<reno_application_person>.<child>.quality
请参阅的“量词”部分。您是指这个正则表达式
%%(.*?)%%
:
String regex = "%%(.*?)%%";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(str);
while (matcher.find()) {
System.out.println(matcher.group(1));
// ^------note to get the group one
}
输出
case.r_object_id
case.status
case.<reno_application_person>.<child>.quality
case.r\u对象\u id
情况.地位
质量
谢谢你的回答,这种方法很有效