Pattern pattern = Pattern.compile("\{(.*?)}");
Matcher matcher = pattern.matcher(string2);
while(matcher.find()){
int i = 1;
System.out.println(matcher.group(i));
i++;
}
正则表达式匹配特殊符号(大括号)中间的字符
本文深入探讨了使用正则表达式从字符串中提取特定模式的方法。通过实例演示了如何利用Pattern和Matcher类来查找并打印出匹配的子串。

被折叠的 条评论
为什么被折叠?



