/
(?<!\\)
(?P<pregunk>(?:\\\\)*) # dont match an odd amount of \ before
(?P<open>\()
(?P<contents>
(?:\\\\)* # even amount of \
(?:
(?:
[^()\\] # not ( or )
|
\\[()\\] # \( \) and \\ are ok
)
|
(?R) # the entire pattern again
)*
(?<!\\)
(?:\\\\)*
)
(?P<close>\))
/
gmx