Search code examples
regexmatlabregex-negationdir

List files with MATLAB which are not .m files


I can list all .m files in the current directory with this code: dir(fullfile('.', '*.m')).

But how to change the regular expression that only files will be listed which have not the ending .m (files without "ending" should be included as well)?

Any help will be appreciated! Thanks in advance!


Solution

  • how about

    fls = dir( fullfile('.','*') );
    sel = arrayfun( @(x) ~x.isdir && ~strcmp(x.name(end-1:end),'.m'), fls );
    fls = fls(sel);