How do Iget a list from multiple rows?
이전 댓글 표시
Hi guys, I have a multiple rows of strings and I want get words that contains "#" all in a single column.
Example:
data = {'he is #coming #today'; 'will #it rain?'};
The desired output:
out = {'#coming';
'#today';
'#it'}
Thanks
댓글 수: 1
Jan
2017년 8월 8일
You forgot the quotes or double quotes. It matters if "strings" means cell strings or the modern string class. Please edit the question and post valid Matlab syntax.
채택된 답변
추가 답변 (1개)
Stephen23
2017년 8월 8일
Using a regular expression is trivially easy:
>> data = {'he is #coming #today'; 'will #it rain?'};
>> C = regexpi(data,'#[a-z]+','match');
>> [C{:}]
ans =
'#coming' '#today' '#it'
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!