Main Content

strrep

Find and replace substrings

Description

example

newStr = strrep(str,old,new) replaces all occurrences of old in str with new.

Note

Only Stateflow® charts that use MATLAB® as the action language support the strrep operator.

Examples

expand all

Replace the substring Hello with Howdy.

h = "Hello, world!"
x = strrep(h, "Hello", "Howdy")

Stateflow chart that uses the strrep operator in a state.

Results from stateflow chart that uses the strrep operator in a state.

Limitations

Introduced in R2021b