I am taking input from a file in following format:
(int1,int2) (int3,int4)
Now I want to read int1, int2, int3 and int4 in my Java code. How ca
String[] ints = "(2,3) (4,5)".split("\\D+"); System.out.println(Arrays.asList(ints)); // prints [, 2, 3, 4, 5]
To avoid empty values:
String[] ints = "(2,3) (4,5)".replaceAll("^\\D*(.*)\\D*$", "$1").split("\\D+"); System.out.println(Arrays.asList(ints)); // prints [2, 3, 4, 5]