String data = "我的1<if test='case == 1'>1</if>我的2<if test='case == 2'>2</if>";
String regex = "<if test='([\\s\\S]*?)'>([\\s\\S]*?)</if>";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(data);
while (matcher.find()) {
String group = matcher.group();
System.out.println(group);
}
Java正则取出每一个匹配的字符串
最新推荐文章于 2024-08-05 03:37:41 发布