50,526
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
String str = "我叫{名字},是干{什么}的";
Pattern pattern=Pattern.compile("\\{([^{|}]*)\\}");
Matcher m=pattern.matcher(str);
List<String> list=new ArrayList<String>();
while(m.find()){
list.add(m.group(1));
}
System.out.println(list);
}
public static void main(String []args) {
String str="我叫{名字},是干{什么}的";
Pattern p2 = Pattern.compile("\\{([^\\{\\}]*)\\}");
Matcher m2 =p2.matcher(str);
while(m2.find()){
System.out.println(m2.group(1));
}
}