Main Content

startsWith

Determine if string starts with substring in Requirements Table block

Since R2022b

Description

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

example

tf = startsWith(str,substr,IgnoreCase=true) checks if str starts 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!" starts with the substring "Hello,".

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

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

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

y = startsWith("Hello, world!","hello,",IgnoreCase=true)

This image shows a requirement that outputs whether the string "Hello, world" starts with the substring "hello," 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