MATLAB: Regexp to filter file names

parsingregexpsort file

I have files such as the following:
s =
'HI_B2_TTTT9_Default452_07052016.xlsx'
'HI_H2G_TTTT7_Default259_070516.xlsx'
'HI_B2C_TTTT9_Default1482_070516.xlsx'
'HI_A1C_TTTT4_468_070516.xlsx'
'HI_G1C_TTTT8_862_07052016.xlsx'
'HI_KA6_TTTT4_148_07052016.xlsx'
'HI_8C_TTTT7_279_Potato_07052016.xlsx'
I only wish to process the first six files and filter out the last one which is a different format than the first six files. Note that even though some of them did not say "Default" in the file names, it is still considered default since it did not specifically mention "Potato" or other keywords.
I try not to filter it out by keywords "Potato" since there may be future files add in this cell array that contains other keywords such as "Carrot", "Bacon", etc (I don't know what they will be yet) other than "Potato". In that case, they will not be filtered out as I wish they would.
Actually I think I figure out the code after looking at your answers?
I used find(cell2mat(regexp(s,'HI_\w+_\TTTT\d_(Default)?\d+_\d+')))
Thank y'all for all the inspiration!!

Best Answer

s={'HI_A1C_TTTT4_468_07052016.xlsx'
'HI_B2_TTTT9_Default452_070516.xlsx'
'HI_GA1C_TTTT8_862_07052016.xlsx'
'HI_HB2C_TTTT7_Default259_070516.xlsx'
'HI_KA6_TTTT4_148_07052016.xlsx'
'HI_B2C_TTTT9_Default1482_070516.xlsx'
'HI_8C_TTTT7_279_Potato.xlsx'}
out=regexp(s,'\w+_\w+_\w+_(Default)?\d+_\d+','match','once')