Main Content

insertAfter

Insert string after substring

Description

example

newStr = insertAfter(str,subStr,new) inserts the string new into the string str after the substring subStr. insertAfter inserts new after every occurrence of subStr.

example

newStr = insertAfter(str,pos,new) inserts new into str after the character position pos.

Note

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

Examples

expand all

Insert text to form the string "Hello there, world!".

str = "Hello, world!";
newStr = insertAfter(str,"Hello"," there");

Stateflow chart that uses the insertAfter operator in a state.

Insert text to form the string "Hello there, world!".

str = "Hello, world!";
newStr = insertAfter(str,5," there");

Stateflow chart that uses the insertAfter 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"

Character position, specified as a positive integer.

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

Example: "Hello"

Limitations

Version History

Introduced in R2021b