%% Delete Text Between Substrings
% Create string arrays. Then delete text that occurs between substrings.
% Create a string. Starting in R2017a, you can create strings using double quotes.

str = "The quick brown fox"

%
% If you are using R2016b, create string arrays using the string function instead of double quotes.
% Delete the text that occurs between the substrings "quick" and " fox". The eraseBetween function deletes the text but does not delete "quick" or " fox".

newStr = eraseBetween(str,"quick"," fox")

%
% Delete substrings from each element of a string array. When you specify different substrings as start and end indicators, they must be contained in a string array or a cell array of character vectors that is the same size as str.

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

%

startPos = ["quick";"the"];
endPos = [" fox";" dog"];
newStr = eraseBetween(str,startPos,endPos)

% Copyright 2012-2020 The MathWorks, Inc.