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!