Hello,
I would like to use a regexp to filter file names contained in a folder. I almost got it, but I have trouble handling cell that output the dir() function…
Let's imagine I have these files in the data folder :
DY463269-F 01-01-2017.xlsxDY463269-F 01-01-2017.xlsxDY463271-8 01-01-2017.xlsxDY466290-M 01-01-2017.xlsx
My code is :
filesList = dir('data/');serialList = regexpi({filesList.name}, '[a-z]{2}[0-9]{6}[a-z\-]{0,2}', 'match')dateList = regexpi({filesList.name}, '[0-9]{2}-[0-9]{2}-[0-9]{2}', 'match')data = cell2struct([serialList; dateList],{'Name','Date'},1)data(3).Name
First, I guess we can do only one regexpi to get both information… But mostly, data(3).Name return me a cell and I would like it to simply be a string.
Any idea to fix this?
Thanks,
Max
Best Answer