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!