A "pseudocode" from the top of my mind:
1- Get rid of the first and last characters (e.g: remove the first "[" and the last "]").
2- Use regex to find the text between brackets.
3- Loop over the matches of step 2 and split them by the "," character.
4- Loop over the splitted String and trim the value before casting it into a float and then put that value in the array in the correct position.
A code sample
public static void main(String[] args) {
String stringArray = "[[0, 0, 0], [1, 1, 1], [2, 2, 2]]";
//1. Get rid of the first and last characters (e.g: remove the first "[" and the last "]").
stringArray = stringArray.substring(1, stringArray.length() - 1);
//2. Use regex to find the text between brackets.
Pattern pattern = Pattern.compile("\\[(.*?)\\]");
Matcher matcher = pattern.matcher(stringArray);
//3. Loop over the matches of step 2 and split them by the "," character.
//4. Loop over the splitted String and trim the value before casting it into a float and then put that value in the array in the correct position.
float[][] floatArray = new float[3][3];
int i = 0;
int j = 0;
while (matcher.find()){
String group = matcher.group(1);
String[] splitGroup = group.split(",");
for (String s : splitGroup){
floatArray[i][j] = Float.valueOf(s.trim());
j++;
}
j = 0;
i++;
}
System.out.println(Arrays.deepToString(floatArray));
//This prints out [[0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [2.0, 2.0, 2.0]]
}