Is there an efficient method to remove leading underscores from a cell array of strings?
Mostrar comentarios más antiguos
Given
a={'rose','_tulip_blue','lilac','_daisy'}
is there an efficient way of stripping the leading underscores to give
b={'rose','tulip_blue','lilac','daisy'}
I tried
strtok(a,'_')
but that gives
b={'rose','tulip','lilac','daisy'}
and misses the '_blue'. I would like to avoid looping through the strings one at a time if possible.
Respuesta aceptada
Más respuestas (1)
AJ von Alt
el 6 de Ag. de 2014
b = regexprep(a,'^_','','emptymatch')
1 comentario
Ken Campbell
el 6 de Ag. de 2014
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!