Similar to this question I want to split my logical expression
A >= 10 AND B <= 20 OR C in ('3', '4')
to A
, >=
, 10
, AND
, B
, <=
, 20
, OR
, C
, in
, ('3', '4')
how can it be done?
I am trying following way(but this doesnt seems to be elegant approach)
String orRules[] = inputRule.split(" OR ");
for (int i = 0; i < orRules.length; i++) {
String andRules[] = orRules[i].split(" AND ");
for (int j = 0; j < andRules.length; j++) {
String[] result = andRules[j].split("(?<=[-+*/])|(?=[-+*/])");
System.out.println(Arrays.toString(result));
}
orRules[i] = String.join(" AND ", andRules);
}
output = String.join(" OR ", orRules);