Problem in displaying a substring

1 vue (au cours des 30 derniers jours)
Nishat Anjum Shaikh
Nishat Anjum Shaikh le 30 Déc 2011
Problem in displaying a substring
Ex: I have this line:-
C:\abc\xyz\myName_1.wav
I want to display only 'myName' from this line

Réponse acceptée

Junaid
Junaid le 30 Déc 2011
Dear.. there can be multiple way. The easy way I think is to parse the string by dividing into tokens. Here is example you requested. lets say your string is in variable a;
a ='C:\abc\xyz\myName_1.wav';
strtok(fliplr(strtok(fliplr(strtok(a,'.')),'\')),'_')
  1 commentaire
Nishat Anjum Shaikh
Nishat Anjum Shaikh le 30 Déc 2011
thanks! it helped.

Connectez-vous pour commenter.

Plus de réponses (1)

Grzegorz Knor
Grzegorz Knor le 30 Déc 2011
doc fileparts
doc strfind
  2 commentaires
Grzegorz Knor
Grzegorz Knor le 30 Déc 2011
In your case:
[pathstr, name, ext] = fileparts('C:\abc\xyz\myName_1.wav')
idx = strfind(name,'_')
disp(name(1:idx-1))
Nishat Anjum Shaikh
Nishat Anjum Shaikh le 30 Déc 2011
thanks!!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings 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!

Translated by