如何拆分String但在括号内保留分隔符?

时间:2016-05-18 06:33:55

标签: java arrays string split

我有一个字符串,

String str = "(A,B),C,D,(E,F,G)";
String[] parts = str.split(",");

我想用逗号分隔,但我需要括号内的逗号

parts[0] = "(A,B)";
parts[1] = "C";
parts[2] = "D";
parts[3] = "(E,F,G)";

0 个答案:

没有答案