Effacer les filtres
Effacer les filtres

Removing Part of A String

3 vues (au cours des 30 derniers jours)
Syed Abbas
Syed Abbas le 27 Déc 2011
Hi, I have a string of numbers of in the format '7646 89:89'. I basically want to remove the numbers following the white space e.g I want '7646 89:89' to become '7649'. Thanks

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 27 Déc 2011
s='7646 89:89';
d=textscan(s,'%f*');
d=d{1};
  1 commentaire
Jan
Jan le 27 Déc 2011
TEXTSCAN is very powerful, and in consequence it is slow.

Connectez-vous pour commenter.

Plus de réponses (1)

Jan
Jan le 27 Déc 2011
Faster than the very powerful TEXTSCAN:
s = '7646 89:89';
d = strtok(s, ' ');
Or simply:
d = strtok(s);
Or:
index = strfind(s, ' ');
d = s(1:index(1));
  1 commentaire
Syed Abbas
Syed Abbas le 27 Déc 2011
Thanks a lot!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by