Separating numbers and characters from input
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
If a user inputs a random amount of characters For example: str=input(prompt,'s'); and they input: 123wd57ab934bd3 how can I separate the numbers and the characters? Thank you!
0 commentaires
Réponses (1)
Andrei Bobrov
le 25 Oct 2016
str = '123wd57ab934bd3';
z = regexp(str,'(\d*)([a-z]*)','tokens');
out = [z{:}];
out = out(~cellfun(@isempty,out));
3 commentaires
Andrei Bobrov
le 26 Oct 2016
str = '123wd57ab934bd3';
z = str2double(regexp(str,'\d*','match'));
Voir également
Catégories
En savoir plus sur Dates and Time 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!