I have an expression as a string below:
(((status==SUBMITTED) && (submit_date>2020-01-03)) &&(dueDate<(proof_date+1)))
I wanted to identify all the inner expressions in the above string as below:
(status==SUBMITTED)
(submit_date>2020-01-03)
(dueDate<(proof_date+1)
((status==SUBMITTED) && (submit_date>2020-01-03))
((status==SUBMITTED) && (submit_date>2020-01-03)) &&(dueDate<(proof_date+1))
Below is my code written in Java:
String expression = "((status==SUBMITTED)&&(submit_date>2020-01-03)&&(dueDate<(proof_date+1)))";
//Matcher m = Pattern.compile("\\((.*?)\\)").matcher(expression);
//Matcher m = Pattern.compile("\\([^()]*\\)").matcher(expression);
Matcher m = Pattern.compile("\\(([^()]*|\\([^()]*|\\))*\\)").matcher(expression);
while(m.find()) {
System.out.println("Group Result: "+m.group(0));
}
However I am not getting the combinations and its only showing the below values:
Group Result: ((status==SUBMITTED)
Group Result: (submit_date>2020-01-03)
Group Result: (dueDate<(proof_date+1)
How can I get all the above combinations. Is there a Regex that can identify this properly?