Main Content

insertAfter

Insert string after specified substring

Description

example

newStr = insertAfter(str,pat,newText) inserts newText into str after the substring specified by pat and returns the result as newStr. If pat occurs multiple times in str, then insertAfter inserts newText after every occurrence of pat.

example

newStr = insertAfter(str,pos,newText) inserts the text specified by newText into str after the position specified by pos.

Note

The operator insertafter is supported only in Stateflow® charts that use MATLAB® as the action language.

Examples

expand all

Insert the text there after a substring.

h = "Hello, world!"
pat = "Hello"
x = insertAfter(h, pat, " there")

Stateflow chart that uses the insertafter operator in a state.

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

Insert text there after a position.

h = "Hello, world!"
x = insertAfter(h, 5, " there")

Stateflow chart that uses the insertafter operator in a state.

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

Limitations

Introduced in R2021b