%% Delete Substrings Between Start and End Positions
% Create string arrays and delete substrings between start and end positions that are specified as numbers.
% Create a string that contains a name. Starting in R2017a, you can create strings using double quotes.

str = "Edgar Allen Poe"

%
% Delete a substring. To delete the middle name and one of the space characters, specify the sixth and 11th positions in the string. The deleted substring includes the sixth and 11th characters.

newStr = eraseBetween(str,6,11)

%
% Delete substrings from each element of a string array. When you specify different start and end positions with numeric arrays, they must be the same size as the input string array.

str = ["Edgar Allen Poe";"Louisa May Alcott"]

%

startsPos = [6;7];
endPos = [11;10];
newStr = eraseBetween(str,startsPos,endPos)

% Copyright 2012 The MathWorks, Inc.