Main Content

extractBefore

Extract substring before position in Stateflow chart

Since R2021b

Description

newStr = extractBefore(str,subStr) returns the substring of str that ends before the first occurrence of the substring subStr.

example

newStr = extractBefore(str,pos) returns the substring of str that ends before the character position pos.

example

Note

The extractBefore operator is not supported in Stateflow® charts that use C as the action language. For similar functionality, use substr.

Examples

expand all

Extract substring "Hello" from a longer string.

str = "Hello, world!";
newStr = extractBefore(str,", world");

Stateflow chart that uses the extractBefore operator in a state.

Extract substring "Hello" from a longer string.

str = "Hello, world!";
newstr = extractBefore(str,6);

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

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

Go to top of page