Remove parenthesis and the contents inside from a string
古いコメントを表示
Is there a neat way to remove a parenthesis and the contents inside from a string. For example the string
A = 'abc (ABC)'
% how to extract 'abc' from A, get rid of ' (ABC)' including the leading whitespace?
One cumbersome solution is:
temp = strsplit(A,'(');
B = strtrim(temp(1));
採用された回答
その他の回答 (1 件)
KSSV
2021 年 1 月 7 日
A = 'abc (ABC)' ;
idx = strfind(A,' (') ;
iwant = A(1:idx-1)
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!