string.insertAfter
string: newstr = insertAfter (str, pat, newtext)
string: newstr = insertAfter (str, pos, newtext)
Insert text after a pattern or position.
newstr = insertAfter (str, pat, newtext)
inserts the text newtext into each element of str after
every non-overlapping occurrence of the substring pat. pat
can be a string array, a character vector, or a cell array of character
vectors, and must either be a scalar, applied to every element of
str, or be of the same size as str and applied
element-wise. If pat is not found in an element, that element is
returned unchanged.
newstr = insertAfter (str, pos, newtext)
inserts newtext after the character position pos, that is,
between the characters at positions pos and pos+1.
pos must be a positive integer not exceeding the length of the
corresponding element of str, and must be either a scalar or the
same size as str.
newtext can be a string array, a character vector, or a cell array of character vectors, and must be either a scalar, inserted at every position, or of the same size as str. newstr is a string array of the same size as str. Missing values in str are preserved, and a missing value in newtext makes the corresponding element of newstr missing.
Source Code: string
insertAfter inserts text right after each occurrence of a substring.
s = string ({'hello world'; 'good day'})
s =
2x1 string array
"hello world"
"good day"
insertAfter (s, ' ', 'big ')
ans =
2x1 string array
"hello big world"
"good big day"