identify lowercase letters, uppercase letters, numbers and spaces
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mireia Boneta Camí
le 22 Oct 2020
Modifié(e) : Walter Roberson
le 23 Oct 2020
Hello everybody, I have this code and I would like that in the cases of the switch identify if the character of a given sentence is a lowercase letter, an uppercase or an space. Thank you very much!
sentence='Hello 22';
for ch=1:length(sentence)
switch sentence(ch)
case %if it is a lowercase letter
%blahblah
case %if it is an uppercase letter
%blahblah
case %if it is an space
%blahblah
end
end
0 commentaires
Réponse acceptée
Walter Roberson
le 22 Oct 2020
Modifié(e) : Walter Roberson
le 23 Oct 2020
https://www.mathworks.com/help/matlab/ref/isstrprop.html is the only practical routine to use for this purpose. If you do not use it then chances become very high that your code will produce the wrong results for characters such as δ and ή and ř
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Matrices and Arrays 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!