www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/TestEndOfStringAgainstMultiplePatternsExample.m

    %% Test End of String Against Multiple Patterns
% Create a string array that contains file names. Determine which file names 
% end with the |.docx|, |.xlsx|, or |.gz| extensions.
str = string({'data.tar.gz','mycode.m','outputs.xlsx','results.pptx'})

%%
pattern = {'.docx','.xlsx','.gz'};
TF = endsWith(str,pattern)

%%
% Display the file names that end with |.docx|, |.xlsx|, or |.gz|. Index back 
% into |str| using |TF|.
str(TF)