%% Insert Text After Start of Path Using Pattern
% Since R2020b
% Create a string array of file names, including full paths. The paths begin with different drive letters.

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

%
% Insert a new folder name after each drive letter. To match the drive letters, create a pattern that matches a single letter using the lettersPattern function, and follows it with the characters ":\". Then call insertAfter.

pat = lettersPattern(1) + ":\"
filenames = insertAfter(str,pat,"Archive\")

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