extract word before and after character
2 ビュー (過去 30 日間)
古いコメントを表示
i want to extract string before "(" and after " " or "," (space comma)
example:
input: pilo(52),iko(54);
result:
pilo
iko
4 件のコメント
採用された回答
Stephen23
2023 年 12 月 20 日
編集済み: Stephen23
2023 年 12 月 20 日
C = {'input: pilo(52),iko(54)'; 'input:iko(54)'; 'input:pilo(52),iko(54)'; 'input:pilo(52),iko(54),op(23)'}
X = regexp(C,'(\w+)\((\d+)','tokens');
X = cellfun(@(c)vertcat(c{:}),X,'uni',0)
X{:}
However... regular expressions are very precise things. Writing them well requires understanding the precise conditions that they should match. Thus usually when someone posts a question with "simplified" text it just delays getting a working solution.
その他の回答 (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!