Main Content
replace
Description
replaces instances of the substring newStr
= replace(str
,old
,new
)old
that occur in the string
str
with the string new
.
Note
The replace
operator is not supported in Stateflow® charts that use C as the action language.
Examples
Input Arguments
Limitations
This operator does not support the use of Stateflow structure fields or messages. For more information about structures in Stateflow, see Access Bus Signals.
Algorithms
The replace
operator replaces sequential substrings. For example,
replace("abc 2 def 22 ghi 222 jkl 2222","22","*")
returns "abc 2
def * ghi *2 jkl **"
. To replace overlapping substrings, use strrep
. For more information, see Replace Repeated Pattern.
Version History
Introduced in R2021b