%% Select Text Before Substring
% Create string arrays and select text that occurs before substrings.
% 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.
% Extract the substring that occurs before the substring " brown". The extractBefore function selects the text but does not include " brown" in the output.

newStr = extractBefore(str," brown")

%
% Create a new string array from the elements of a string array. When you specify different substrings as positions, they must be contained in a string array or a cell array that is the same size as str.

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

%

newStr = extractBefore(str,[" brown";" dog"])

% You also can specify one substring as a position that is applied to all elements of the input string array.
% Copyright 2012-2020 The MathWorks, Inc.