%% Replace Text Within Inclusive and Exclusive Boundaries
% Replace text from string arrays within boundaries that are forced to be inclusive or exclusive. replaceBetween replaces the boundaries along with the text when the boundaries are inclusive. replaceBetween does not replace the boundaries when the boundaries are exclusive.
% Starting in R2017a, you can create strings using double quotes.

str = "small|medium|large"

%
% Replace the text between sixth and 13th positions, but do not replace the characters at those positions.

newText = "regular";
newStr = replaceBetween(str,6,13,newText,'Boundaries','exclusive')

%
% Replace the text between two substrings, and also the substrings themselves.

str = "The quick brown fox jumps over the lazy dog"

%

newText = "red bird flies";
newStr = replaceBetween(str,'brown','jumps',newText,'Boundaries','inclusive')

% Copyright 2012 The MathWorks, Inc.