How can I split a string?

1 vue (au cours des 30 derniers jours)
pamela sulis
pamela sulis le 25 Nov 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?

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by