How do Iget a list from multiple rows?
Mostrar comentarios más antiguos
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 comentario
Jan
el 8 de Ag. de 2017
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.
Respuesta aceptada
Más respuestas (1)
Stephen23
el 8 de Ag. de 2017
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'
1 comentario
Bernard Opoku
el 9 de Ag. de 2017
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!