%% Detect Text at End of String
% Create a string array that contains file names. Determine which file names end with the .gz extension.
% Starting in R2017a, you can create strings using double quotes.

str = ["abstract.docx","data.tar.gz","mycode.m"; ...
       "data-analysis.ppt","results.ptx","temp-archive.gz"]

%
% If you are using R2016b, create string arrays using the string function instead of double quotes.
% Return a logical array where the position of each element equal to 1 corresponds to the position of a string in str that ends with .gz.

pat = ".gz";
TF = endsWith(str,pat)

%
% Display the file names that end with .gz. Index back into str using TF.

str(TF)

% Copyright 2012-2020 The MathWorks, Inc.