I have some expressions with AND
, OR
operators. +
being AND
, /
being OR
. I need to extract expressions within parentheses separated by operators.
Example:
Expression Output
(A + B)/(C + D) (A + B), (C + D)
(A / B)+(C / D) (A / B), (C / D)
(A + B / C)+(A / B) (A + B / C), (A / B)
Expressions can have any combination. All I need is to look at the logical operator & get data in the parentheses.
exp.split("((?<=&&)|(?=&&)|(?<=\\|\\|)|(?=\\|\\|)|(?<=\\()|(?=\\()|(?<=\\))|(?=\\)))");
But this splits on each character. I need regex to look for operators & split on that giving me data inside the parentheses as quoted in the example above.
If i also want the operator along with data how could it be done?
Example :
(A + B)/(C + D) should give me (A + B), /, (C + D)
(A + B / C)+(A / B) should give me (A + B / C), +, (A / B)