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