I'm building a query builder interface in which the expression has to be validated for ambiguity. I need a correct regex syntax for the following example expressions. The criteria is, at a certain level (i.e., with a set of brackets), both `+` and `-` cannot be present. For example `(A + B + C)` is right were as `(A + B - C)` is wrong. I validated it by checking if both `+` & `-` are present. I'm not sure how to do this correctly if there is more than one level. 

```
For ex: (A + (B - C - D) - E)

```

Here, though `(B - C - D)` is not ambiguous but on the whole it is. I'm planning to solve it by replacing all the inner brackets with a character `X` which will look like: `(A + X - E)` and then verify if it has more than both `+` and `-` symbols in it. I used regex `\((.*?)\)` to select the elements between `(` & `)` and it filtered `(A + (B - C - D)` instead of `(B - C - D)`. How should I modify my regex to avoid this problem. Also it should work for the following cases too. 

```
(A + H + (B + (C + D - E)) = (A + H + X)
(A + H + (B + (C + D - E) - F) - (G + H - I)) = (A + H + X - X)

```

If there is a better approach compared to the above, I'm happy to use that as well.