67,513
社区成员
发帖
与我相关
我的任务
分享
String str="[1, 1, 1, 2, 2, 3, 1, 1, 1, 1, 2, 1, 1, 1, 3, 3, 1]";
String result=str.replaceAll("(?:,\\s?[02-9]+)+,", "],[");
String str="[1, 1, 1, 2, 2, 3, 1, 1, 1, 1, 2, 1, 1, 1, 3, 3, 1]";
Matcher m=Pattern.compile("1(?:,\\s?1)*").matcher(str);
List<String> list=new ArrayList<String>();
while(m.find()){
list.add("["+m.group()+"]");
}