String and number please
显示 更早的评论
Q/ write program to read string then print the count of numbers & the number in the string.
Ex: mosul42city6 output: count= 3 num.= 4 2 6
1 个评论
Adam Danz
2021-3-23
This is obviously homework. Users of the forum should not be asking for solutions to their homework and volunteers should not be giving full solutions to homework problems.
回答(1 个)
David Hill
2021-3-23
a ='mosul42city6';
b=regexp(a,'\d');
count=length(b);
num=a(b)-'0';
4 个评论
Walter Roberson
2021-3-23
We discourage volunteers from giving complete homework solutions.
John D'Errico
2021-3-24
Please don't do homework assignments for people. It does not help them, nor does it help the site, as that just encourages other stuents to post their homework.
David Hill
2021-3-24
Would you like me to delete?
Walter Roberson
2021-3-24
You could rewrite to provide guidance instead of complete code. For example you could describe that regexp with '\d' can be used to locate digits.
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!