I want to match the following text:
(valuex) AnySingleWord (valuey)
I want to capture the text of valuex,valuey within the brackets. The tough thing is valuex,valuey both can contain brackets as well. For example
((value1) AnySingleWord (value2)) AnySingleWord ((value3) AnySingleWord (value4))
Then my valuex should be
(value1) AnySingleWord (value2)
and valuey should be
(value3) AnySingleWord (value4)
Can regex do something like counting the number of open bracket has passed, and match things until the right close bracket found? many thanks.
PS: I can limit number of open/close bracket pairs to 2-3, if this is small enough to be solvable by Regex