Main Content

endsWith

Determine if string ends with substring in Stateflow chart

Since R2021b

Description

tf = endsWith(str,substr) returns 1 (true) if the string str ends with the substring substr, and returns 0 (false) otherwise.

example

tf = endsWith(str,substr,IgnoreCase=true) checks if str ends with substr, ignoring any differences in letter case.

example

Note

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

Examples

expand all

Return a value of 0 (false) because the string "Hello, world!" does not end with the substring "World!".

str = "Hello, world!";
substr = "World!";
x = endsWith(str,substr);

Stateflow chart that uses the endswith operator in a state.

Return a value of 1 (true) because the string "Hello, world!" ends with the substring "World!" when you ignore case.

str = "Hello, world!";
substr = "World!";
x = endsWith(str,substr,IgnoreCase=true);

Stateflow chart that uses the endswith operator in a state, ignoring case.

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

  • 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