1
我想提取多個括號之間的字符串,但它也應該沒有任何括號。這是我現在得到提取可選括號之間的字符串
Pattern pw = Pattern.compile("\\(?(.*)\\)?\\^\\(?(.*)\\)?");
Matcher m = pw.matcher("2+1^(3+4)");
if(m.find()){
System.out.println(m.group(1));
System.out.println(m.group(2));
}"
此打印:
2+1
3+4)
而應該是:
2+1
3+4
任何幫助表示讚賞!