Main Content

insertBefore

Insert string before substring in Stateflow chart

Since R2021b

Description

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

example

newStr = insertBefore(str,pos,new) inserts new into str before the character position pos.

example

Note

The insertBefore 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 = insertBefore(str,","," there");

Stateflow chart that uses the insertBefore operator in a state.

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

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

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

  • This operator does not support the use of Stateflow structure fields or messages. For more information about structures in Stateflow, see Access Bus Signals.

Version History

Introduced in R2021b