Separating numbers and characters from input
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Andrei Bobrov
am 25 Okt. 2016
str = '123wd57ab934bd3';
z = regexp(str,'(\d*)([a-z]*)','tokens');
out = [z{:}];
out = out(~cellfun(@isempty,out));
3 Kommentare
Andrei Bobrov
am 26 Okt. 2016
str = '123wd57ab934bd3';
z = str2double(regexp(str,'\d*','match'));
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!