Main Content

endsWith

Determine if string ends with substring in Requirements Table block

Since R2022b

Description

tf = endsWith(str,substr) returns 1 (true) if the string str ends with the substring substr, and returns 0 (false) otherwise. Use this operator in the Requirements Table block.

example

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

example

Examples

expand all

In a Requirements Table block, create a requirement that checks if the string "Hello, world!" ends with the substring "world!".

y = endsWith("Hello, world!","world!")

This image shows a requirement that outputs whether the string "Hello, world" ends with the substring "world!".

In a Requirements Table block, create a requirement that checks if the string "Hello, world!" ends with the substring "World!", regardless of case.

y = endsWith("Hello, world!","world!",IgnoreCase=true)

This image shows a requirement that outputs whether the string "Hello, world" ends with the substring "World!" regardless of case.

Input Arguments

expand all

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

Example: "Hello"

Data Types: string

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

Example: "Hello"

Data Types: string

Limitations

  • This operator does not support the use of Simulink.Bus object fields.

Version History

Introduced in R2022b