Consider the following cell array of strings containing filenames:
A = { 'abcout.txt';
'outabcd.txt';
'outabcef.png';
'outout.txt' }
I'd like to find all .txt-files starting with "out".
I could do it as following:
filenames = regexp( A ,'out\w*.txt');
filenames = A( cellfun(@(x) ~isempty(x) && x == 1,filenames) )
returning the desired output:
filenames =
'outabcd.txt'
'outout.txt'
But I wonder how I could use regexp to skip the cellfun step?
The following almost works:
filenames = regexp( A ,'out\w*.txt','match');
filenames = [filenames{:}]'
but it returns also the first string, which is invalid (and not even correctly displayed):
filenames =
'out.txt'
'outabcd.txt'
'outout.txt'
How do I need to modify: 'out\w*.txt' ?