MATLAB: Matching substrings with regexp

parseregexpstrings

I'm trying to identify the subexpressions of a formula such as (real cases much longer):
y = ((a + b) * (c / d) + ( e + f ))
The subexpressions are always separated by pairs of parenthesis as in the example above. It seems like I should be able to use a regular expression with a rule like (intuitively) match "an initial left parenthesis, any characters (but no parenthesis), and a terminating right parenthesis" to get:
(a + b) (c / d) (e + f)
Can anybody suggest a regular expression to do this? Or any way other than a regular expression?

Best Answer

subexpressions = regexp(expression, '\([^()]+\)', 'match')
will match any sequence with two brackets enclosing one or more non-bracket.