Use \([^)]*\)as a delimiter, either in split, or java.util.Scanner, etc., or just use it to replace with "".
In Java:
System.out.println(Arrays.toString(
"abc(xyz)def(123)".split("\\([^)]*\\)"))
);
System.out.println(
"abc(xyz)def(123)".replaceAll("\\([^)]*\\)", "")
);
source
share