%% Detect Starts of Paths Using Pattern
% Since R2020b
% Create a string array that has references to files, including full paths for local files and URLs for remote ones.

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

%
% To find the paths that start with a drive letter, create a pattern that matches one letter followed by a colon.

pat = lettersPattern(1) + ":"

%
% Determine which elements of str start with that pattern. The pattern pat does not match "https:" because lettersPattern(1) matches only one letter.

TF = startsWith(str,pat)

%
% Display the matching file names.

str(TF)

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