String str = "[a,b,c],[d,e,f,g],[h,i,j],[k,l]"; String arr[] = str.split("\\]+,"); for(int i=0;i arr[i]=arr[i]+"]"; } for(String s:arr){ System.out.println(s); }