specific pattern from the file name
Show older comments
I want to extract the project number from the file name
example the file fame is: 'abcdd-22_Z12'
the project number should be Z12 for sure it is dynamic name could in the next file name Z11 for intance.
which expression I should use
Accepted Answer
More Answers (1)
Walter Roberson
on 26 Jul 2019
[~, basename, ext] = fileparts(FileName);
parts = strsplit(basename, '_');
project = parts{end};
In some cases this can be simplified: for example if the directory and extension are already removed from FileName then
project = regexp(FileName, '(?<=_).*', 'match');
1 Comment
ayman mounir
on 27 Jul 2019
Categories
Find more on Encryption / Cryptography in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!