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!