Replace substrings between start and end points
replaces
substrings in newStr
= replaceBetween(str
,startStr
,endStr
,newText
)str
with the text in newText
.
The substrings that are replaced occur between the substrings startStr
and endStr
.
However, replaceBetween
does not replace startStr
and endStr
themselves. replaceBetween
returns
the result as newStr
. The newText
argument
can have a different number of characters than the substring it replaces.
If str
is a string array or a cell array
of character vectors, then replaceBetween
replaces
substrings in each element of str
. The output argument newStr
has
the same data type as str
.
forces
the starts and ends specified in any of the previous syntaxes to be
either inclusive or exclusive. They are inclusive when newStr
= replaceBetween(___,'Boundaries',bounds)bounds
is 'inclusive'
,
and exclusive when bounds
is 'exclusive'
.
For example, replaceBetween(str,startStr,endStr,newText,'Boundaries','inclusive')
replaces startStr
, endStr
,
and all the text between them with the text specified by newText
.