string_last_pos

这个函数会返回一个字符串内一个子字符串的实例的字符位置,从字符串的末尾搜索到开头 (所以 string_pos() 的反向,如果找不到搜索字符串,函数会返回0,或搜索字符串的第一个字符的位置,如果是请记住,对于旧版支持字符串是从1开始索引的,因此1是字符串中的第一个位置,而不是您可能期望的0。

 

语法:

string_last_pos(substr, str);

参数类型描述
substrString在字符串中寻找的子字符串。
strString字符串。

 

返回:

Real

 

例子:

if (string_last_pos(",", text) != 0)
{
    string_insert(name, text, string_last_pos(",", text));
}

上面的代码在存储在变量 “text” 中的字符串中搜索从字符串末尾开始搜索的逗号。如果找到一个,则在该位置插入子字符串 “name”。