62,616
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
String str = "(1) P ((2)@!)";
Pattern p = Pattern.compile("(\\(\\d+\\))\\s*(\\w+)\\s*\\((\\(\\d+\\))(.+)\\)");
Matcher m = p.matcher(str);
String[] arr = null;
if(m.find()) {
arr = new String[]{m.group(1),m.group(2),m.group(3),m.group(4) };
}
for(String s : arr) {
System.out.println(s);
}
}