What should I do to for separate (test(1,2) , test(3,4)) as test(1,2) and test(3,4). What can I use as delimiter value instead of x here? Thanks
StringTokenizer tokenizer = new StringTokenizer(str, "x");
What should I do to for separate (test(1,2) , test(3,4)) as test(1,2) and test(3,4). What can I use as delimiter value instead of x here? Thanks
StringTokenizer tokenizer = new StringTokenizer(str, "x");
Try this :-
String s = "(test(1,2) , test(3,4))";
s=s.substring(1).substring(0,s.length()-2);
String[] arr = s.split(" ,");
System.out.println(arr[0].trim());
System.out.println(arr[1].trim());
Use String.split()
instead:
String s = "test(1,2), test2(4,5), test3(2,3)";
String[] arr = s.split("(?<=\\w*[(]\\d,\\d[)]),");
System.out.println(Arrays.toString(arr));
Output:
[test(1,2), test2(4,5), test3(2,3)]