%% Insert Text Before Substring
% Create string arrays and insert text before substrings.
% Starting in R2017a, you can create strings using double quotes.

str = "bread cheese wine"

%
% Insert a comma before each space character in the string. The insertBefore function inserts text before each matching substring.

newStr = insertBefore(str," ",",")

%
% Insert substrings into each element 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 fox jumps";"over the dog"]

%

newStr = insertBefore(str,[" fox";" dog"],[" brown";" lazy"])

% Copyright 2012 The MathWorks, Inc.