Main Content

startsWith

确定 Stateflow 图中字符串是否以子字符串开头

自 R2021b 起

描述

示例

如果字符串 str 以子字符串 substr 开头,则 tf = startsWith(str,substr) 返回 1 (true),否则返回 0 (false)。

示例

tf = startsWith(str,substr,IgnoreCase=true) 检查 str 是否以 substr 开头,忽略任何字母大小写差异。

注意

使用 C 语言作为动作语言的 Stateflow® 图不支持 startsWith 运算符。

示例

全部展开

返回值 0 (false),因为字符串 "Hello, world!" 不以子字符串 "hello" 开头。

str = "Hello, world!";
substr = "hello";
x = startsWith(str,substr);

Stateflow chart that uses the startswith operator in a state.

返回值 1 (true),因为在忽略大小写时字符串 "Hello, world!" 以子字符串 "hello" 开头。

str = "Hello, world!";
substr = "hello";
x = startsWith(str,substr,IgnoreCase=true);

Stateflow chart that uses the startswith operator in a state.

输入参数

全部展开

输入字符串,指定为字符串标量。用双引号将文字字符串引起来。

示例: "Hello"

子字符串,指定为字符串标量。用双引号将文字字符串引起来。

示例: "Hello"

限制

版本历史记录

在 R2021b 中推出