One can read all over the web how it is impossible to use regular expressions to match nexted parenthesis. However MATLAB has this cool feature called 'dynamic regular expressions' that allow one to insert some MATLAB code to do all kinds of special 'gymnastics'. Is there a way to use this feature to count instances of parenthesis and, in turn, find their matches? Consider the following string:
g = 'asdf (( dwer e: ( asdedsdskek))::)asd fg ( qwe 4 dfy5 57) q34 dqa5';
g = 'asdf (( (dwer ) e: ( asdedsdskek))::)asd fg ( qwe 4 dfy5 57) q34 dqa5';
g = 'asdf ( dwer e: )asd fg ( qwe 4 dfy5 57) q34 dqa5';
Specifically, my need is only to match the first left parenthesis with its partner but one would think the more general solution of matching all sets of parenthesis is feasible with dynamic regular expressions. If anyone can help with this, it would be much appreciated.