strings.ends_with
strings.ends_with(value, suffix)
说明
函数接受两个字符串 (value, suffix)。如果后缀不为空且位于值末尾,则返回 true。
形参数据类型
STRING,STRING
返回值类型
BOOL
代码示例
以下代码示例展示了 strings.ends_with 函数的一些使用方式。
示例:返回 true
如果找到位于值末尾的后缀,则返回 true。
strings.ends_with(target.hostname, "com") = true
示例:返回 false
如果后缀不在值末尾,则返回 false。
strings.ends_with(target.hostname, "com") = false
示例:如果两个值完全相同,则返回 false
当后缀和值相同时,返回 false。
target.hostname != "example.com"
strings.ends_with("str", "str") = true
示例:当后缀为空时返回 false
当后缀为空字符串时,返回 false。
target.hostname != "example.com"
strings.ends_with("str", "") = false
示例:当值为空时返回 false
当值为空字符串时,返回 false。
target.hostname != "example.com"
strings.ends_with("", "str") = false
示例:当后缀和值为空时,返回 false
当后缀和值为空字符串时,返回 false。
target.hostname != "example.com"
strings.ends_with("", "") = false