I have a String to represent an entity and its properties(also an entity) like :
String input = "apple{shape,color},orange{taste,price}";
I want it to split to an array :
array[0] = apple{shape,color};
array[1] = orange{taste,price};
any words even it has no {xxx}
can be considered as a entity so do shape and color.
So if I have a String input = "shape,color"
array[0] = shape
array[1] = color
The depth may be more:String input = "Fruit{apple{shape,color},orange{taste,price}}";
array[0] = Fruit{apple{shape,color},orange{taste,price}}
I tried this but it does not work well,
public static String[] split(String input){
String[] groups = input.split("(?<=\\}),(?=\\w+\\{)");
return groups;
}