Regex - everything but anything within parenthesis

Viewed 116

Having, let's say:

fieldA=20 and (fieldB=date() and (fieldC=35 and fieldD=40)) and fieldE = 100

I'm trying to replace outter "and" words, something:

fieldA=20 zzz (fieldB=date() and (fieldC=35 and fieldD=40)) zzz fieldE = 100

I've tried for hours, with no success. I could find some answers regarding how to get everything inside either parenthesis or brackets. The following expression is getting everything inside parenthesis, but I don't actually know how to write an expression that ignores just that:

\(([^()]*+|(?R))*\)    # retrieves "(fieldB=date() and (fieldC=35 and fieldD=40))"

Any help would be appreciated.

2 Answers
Related