This is probably too confusing, but the hay ...
The first thing we need to do is remove all the crap we don't need ...
String[] crap = {"(", ")", ",", ";"}; String text = "(123, 234; 345, 456) (567, 788; 899, 900)"; for (String replace : crap) { text = text.replace(replace, " ").trim(); }
Next, we need to separate the individual elements of the string into a more manageable form.
String[] values = text.split(" ");
Then we need to convert each String value to an int value
int[] iValues = new int[values.length]; for (int index = 0; index < values.length; index++) { String sValue = values[index]; iValues[index] = Integer.parseInt(values[index].trim()); }
Then we print the values ...
for (int value : iValues) { System.out.println(value); }
source share