string_starts_with

此函数用于检查字符串是否以给定子字符串开头。如果有,则返回 true,否则返回 false

 

语法:

string_starts_with(str, substr);

参数类型描述
strString要检查给定子字符串在开头是否出现的字符串
substrString字符串开头的子字符串

 

返回:

Boolean

 

例子:

var _message = "Hello world";
if string_starts_with(_message, "Hello")
{
    show_debug_message("Greeting successful!");
}

上面的代码首先创建一个字符串,并将其存储在临时变量 _message 中。然后,它检查字符串是否以字符串 "Hello" 开头,如果是,则显示一条调试消息。