跳至主要内容

endswith 函数

endswith 接受两个值:要检查的字符串和后缀字符串。如果第一个字符串以该确切后缀结尾,则该函数返回 true。

代码块
endswith(string, suffix)

示例

代码块
> endswith("hello world", "world")
true

> endswith("hello world", "hello")
false
  • startswith 接受两个值:要检查的字符串和前缀字符串。如果字符串以该确切前缀开头,则该函数返回 true。