how to extract file name

Hi I am trying to extract a file name but i don´t want to extract it´s entire name.For example if i have 30 people with 3 different expressions each. I name them as 0101.txt...0103.txt,...,3001.txt...3003.txt. How could i extract only the first 2 digits that represent individual person? Thank you.

 Accepted Answer

per isakson
per isakson on 12 Dec 2017
Edited: per isakson on 12 Dec 2017
If I got you question right
cac = { '0101.txt', '0103.txt', '3001.txt', '3003.txt' };
out = regexp( cac, '^\d{2}', 'match' );
out{:}
outputs
ans =
'01'
ans =
'01'
ans =
'30'
ans =
'30'

1 Comment

i need to continue with another process on this..but at this stage i got your answer. Thank you very much sir.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Asked:

on 12 Dec 2017

Commented:

on 12 Dec 2017

Community Treasure Hunt

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

Start Hunting!