Skip commas inside brackets when the expression has operators
9 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I am trying to split a string
"A(B,'C'),D(E,'F'),'==','G','H"
using strsplit so that I get these separately
A(B, 'C')
D(E, 'F')
'=='
'G'
'H'
Any help would be appreciated.
Dhanesh
1 件のコメント
回答 (2 件)
Pravarthana P
2022 年 4 月 4 日
Hi Dhanesh Kumar,
I understood that you are trying to split the string at commas except that within the brackets.
For example,
test = 'Ram,C,D,GH(cat,abc,6),,xyz';
regexp(test,'\w+(\([^)]+\))?', 'match')
Hope this helps you!!
0 件のコメント
Xingwang Yong
2022 年 4 月 4 日
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!