public static void main(String[] args) {
String s = "[[1,2],[3,4],[5,6],[7,8]]";
String[] s1 = s.replaceAll("],", "]#"轿激).split("#");
String[][] arr = new String[s1.length][];
for(int i=0;iString[] s2 = s1[i].split(",");
arr[i] = new String[s2.length];
梁帆贺 for(int j=0;jarr[i][j] = s2[j].replaceAll("\\[|\\]", "");
}
}
for(String[] i:arr) {
System.out.println(Arrays.toString(i));
}
橡派 }
通过正则表达尺纯搏式,取出来陵祥裤宽
~~~~~~~~~~~~~~~~~
public class Vector {
public static void main(String[] args) 滑大{
String str="[[1,2],[3,4],[5,6],[7,8]]";
String str1=null;
str1=str.replace('[', '瞎让明 ');
str1=str1.replace(']', ' ');
str1=str1.replace(',', ' ');
str1=str1.replaceAll(" ", 磨告"");
char[] str2=str1.toCharArray();
for(char i:str2 ){
System.out.println(i);
}
}
}