%% Select Substrings Before Position
% Create strings before specified positions.
% Starting in R2017a, you can create strings using double quotes.

str = "Edgar Allen Poe"

%
% Select the substring before the sixth character.

newStr = extractBefore(str,6)

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

str = ["Edgar Allen Poe";"Louisa May Alcott"]
newStr = extractBefore(str,[6;7])

%
% Select substrings from each element and specify the same position.

newStr = extractBefore(str,12)

% Copyright 2012 The MathWorks, Inc.