How can I split a string?

1 visualización (últimos 30 días)
pamela sulis
pamela sulis el 25 de Nov. de 2015
Respondida: Walter Roberson el 25 de Nov. de 2015
Hi, I have this string '0231563972' and i want to split it, put a space between the number: '0 2 3 1 5 6 3 9 7 2'. Can you give me suggestions?

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de Nov. de 2015
S = '0231563972';
newS = regexprep(S, '(.)(?=.)', '$1 ');
or
newS = strjoin(num2cell(S),' ');

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by