To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
Hi all, I don't know anything about regular expressions and I have two questions:
No products are associated with this question.
1. Read here about the Regular Expressions
str = 'cos(exp(a_2/4*d_1^3-ee_4)+d_85)';
fun = regexp(str,'\w*(?=\()','match') var = regexp(str,'(a|d|ee)_\d*','match')
Another way to get good at regular expressions is to practice on Cody with all the problems that have been tagged "regexp".
Assuming a string x,
[a, b] = regexp(x, '(a|d|(ee))(_)([0-9]*)', 'start', 'end')
will find the start and end indices of your "variables." This will allow for a variable a_0 which may or may not be desired. Without a rule for defining functions that handles the numerous edge cases, creating the regexp is difficult. Andrei's answer seems reasonable to me.