Separating numbers and characters from input
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Andrei Bobrov
2016-10-25
str = '123wd57ab934bd3';
z = regexp(str,'(\d*)([a-z]*)','tokens');
out = [z{:}];
out = out(~cellfun(@isempty,out));
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!