Main Content

本页采用了机器翻译。点击此处可查看英文原文。

endsWith

确定字符串是否以 Requirements Table模块中的子字符串结尾

自 R2022b 起

描述

示例

如果字符串 str 以子字符串 substr 结尾,则 tf = endsWith(str,substr) 返回 1 (true),否则返回 0 (false)。在 Requirements Table模块中使用此运算符。

示例

tf = endsWith(str,substr,IgnoreCase=true) 检查 str 是否以 substr 结尾,忽略字母大小写差异。

示例

全部展开

Requirements Table模块中,创建一个需求,检查字符串 "Hello, world!" 是否以子字符串 "world!" 结尾。

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

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

Requirements Table模块中,创建一个需求,检查字符串 "Hello, world!" 是否以子字符串 "World!" 结尾,无论大小写。

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.

输入参数

全部展开

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

示例: "Hello"

数据类型: string

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

示例: "Hello"

数据类型: string

限制

  • 该运算符不支持使用Simulink.Bus对象字段。

版本历史记录

在 R2022b 中推出

另请参阅

| |