Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Matcher find()指定一个特定的重复模式_Java_Regex - Fatal编程技术网

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
情况.地位
质量

谢谢你的回答,这种方法很有效