Skip commas inside brackets when the expression has operators
8 views (last 30 days)
Pravarthana P on 4 Apr 2022
Hi Dhanesh Kumar,
I understood that you are trying to split the string at commas except that within the brackets.
The function “regexp” can be used to match the expression and eliminate the commas:
test = 'Ram,C,D,GH(cat,abc,6),,xyz';
Reference link: Function "regexp"
Hope this helps you!!
Xingwang Yong on 4 Apr 2022
expr1 = '(?<=\([^)]*),(?=.*\))'; % comma inside parenthesis, like '(..., ...)'
index_comma_in_paren = regexp(line, expr1);
Once I did this for my file exchange submission alignMatrix.m. Hope it helps.