Main Content

erase

Delete substrings within strings

Description

example

newStr = erase(str,match) deletes all occurrences of match in str and returns the remaining text as newStr.

Note

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

Examples

expand all

Delete a substring from Hello, world!

h = "Hello, world!"
x = erase(h, ", world")

Stateflow chart that uses the erase operator in a state.

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

Limitations

Introduced in R2021b