1

I would like to open a dialog box to select a file and show all files with a certain extension, but exclude certain filenames based on pattern match (regex or otherwise).

For example, I want to show CSV files, but not ones that have 'abc' in their filename.

To show ALL .csv files I can do (NOT what I want):

[filename, pathname] = uigetfile({'*.csv', 'CSV Files (*.csv)'});

With regular expressions, I can successfully exclude filenames with 'abc' as follows (thanks to How to negate specific word in regex?):

filenames = {'myfile.csv'; 'myfile-abc.csv'}
regexp(filenames, '^(?!.*abc).*.csv')

However, the following does not work:

[filename, pathname] = uigetfile({'^(?!.*abc).*.csv', 'CSV Files (*.csv)'});

How can I negate a word from occuring in the filename? It seems I can only do positive wildcards (*) but not negation.

Community
  • 1
  • 1
alexperrone
  • 667
  • 5
  • 12

1 Answers1

0

No it seems to be impossible. If you look into the implementation in Matlab, you will find that the Java standard dialog is called. Either you develop your own dialog or you check later the outputs of the dialog.

Sebastian
  • 124
  • 1
  • 9