Main Content

erase

Delete substrings within strings

Description

example

newStr = erase(str,substr) deletes instances of the substring substr that occur in the string str.

Note

The erase operator is not supported in Stateflow® charts that use C as the action language.

Examples

expand all

Delete a substring to form the string "Hello!"

str = "Hello, world!";
newstr = erase(str,", world");

Stateflow chart that uses the erase operator in a state.

Input Arguments

expand all

Input string, specified as a string scalar. Enclose literal strings with double quotes.

Example: "Hello"

Substring, specified as a string scalar. Enclose literal strings with double quotes.

Example: "Hello"

Limitations

Version History

Introduced in R2021b