replaceBetween
Replace substrings between start and end points
Syntax
Description
replaces substrings in newStr
= replaceBetween(str
,startPat
,endPat
,newText
)str
with the text in
newText
. The substrings that are replaced occur between the
substrings startPat
and endPat
. However,
replaceBetween
does not replace startPat
and endPat
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,startPat,endPat,newText,'Boundaries','inclusive')
replaces startPat
, endPat
, and all the text
between them with the text specified by newText
.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced in R2016b