%% Delete File Paths Using Pattern
% Since R2020b
% Create a string array of file names, including full paths.

str = ["C:\Temp\MyReport.docx";
       "C:\Data\Experiment1\Trial1\Sample1.csv";
       "C:\Temp\Slides.pptx"]

%
% Delete the paths, leaving only file names. To match paths, create a pattern using the wildcardPattern function that matches all text that includes a final "\" character. Use that pattern with the erase function.

match = wildcardPattern + "\"
filenames = erase(str,match)

%
% For a list of functions that create pattern objects, see pattern.
% Copyright 2020 The MathWorks, Inc.