java正则匹配字符串最外层{}里的内容,包含{}

String s = "start {sffff''{adfaw3ea}wfewrfwef----}";

String regex = "(?<=\\{).*(?=\\})";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(s);
while (matcher.find()) {
System.out.println(matcher.group(0));
}
输出:{sffff''{adfaw3ea}wfewrfwef----}

 

 

 
posted @ 2022-11-17 13:26  jokerMM  阅读(312)  评论(0编辑  收藏  举报