Extract single-digit and double-digit numbers at the same time from a cell array with "regexp"
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I am trying to extract the numbers from the following cell array:
a={'1','3','6-10','11-20'};
If I use regexp, the number 10, 11 and 20 are also split:
b=regexp(a,'[0-9]','match');
b{:}
I would like to have the number 10, 11 and 20 unsplitted. How to do it, maybe still with regexp?
2 commentaires
Réponse acceptée
Les Beckham
le 12 Fév 2024
Modifié(e) : Les Beckham
le 12 Fév 2024
a={'1','3','6-10','11-20'};
b=regexp(a,'[0-9]+','match'); %<<< add the + to match multiple numeric characters
b{:}
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!