Filter löschen
Filter löschen

take a part from name

1 Ansicht (letzte 30 Tage)
Ayman Mounir
Ayman Mounir am 23 Dez. 2020
Kommentiert: Ayman Mounir am 23 Dez. 2020
Hello everyone;
I have a file name such as file.name='AA_BB_CC12_DD' ; and I want to extract 'CC12' part, but the location of 'CC12' can be in the first part of the file.name or at the end in addition, it could combined with more than one number digit for expample: it can be 'CC5555' or 'CC1'.
Thanks in advance.
Regards,

Akzeptierte Antwort

Ive J
Ive J am 23 Dez. 2020
Bearbeitet: Ive J am 23 Dez. 2020
If the structure of your string always conforms to the above leading/trailing underlines, you can use regexp:
str = 'CC5_ts1_CC534_CC322_F4324_CC1_U84';
regexp(str,'(?<=(_|^))CC\d+', 'match')
1×4 cell array
{'CC5'} {'CC534'} {'CC322'} {'CC1'}
  1 Kommentar
Ayman Mounir
Ayman Mounir am 23 Dez. 2020
Thanks a lot it works and Happy new year

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by