跳至主要内容

startswith 函数

startswith 接收两个值:要检查的字符串和前缀字符串。如果字符串以该确切前缀开头,则该函数返回 true。

代码块
startswith(string, prefix)

示例

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

> startswith("hello world", "world")
false
  • endswith 接收两个值:要检查的字符串和后缀字符串。如果第一个字符串以该确切后缀结尾,则该函数返回 true。