AppleScript-字符串

使用规则
字符串需使用双引号,不能使用单引号
字符串中有引号时,需使用转义字符"",如"\他说:"你好!""

字符串拼接--用&

set str to "hello world"
set str2 to "good morning "
set str3 to str2 & str

获取字符串长度-- the length of

set num to the length of str3

字符串转类型

set countStr to 100 as string

字符串切割

set str4 to "a-b-c-d-e"

方法1:获取由每一个字符组成的数组
get every character of str4
方法2:按照指定的分隔符分割字符串

set oldDelimiters to AppleScript's text item delimiters --记录开始的去限器
set AppleScript's text item delimiters to "-" --设置分隔符
set str4Arr to every text item of str4 -- 分割
set AppleScript's text item delimiters to oldDelimiters -- 恢复原来的去限器
get str4Arr --获取数组

字符串的比较

begins with 或starts with ——以...开头
does not start with ——不以。。。开头
ends with ——以。。。结束
is equal to —— 相等
comes before —— 在。。。之前。比较两字符的ascii码
comes after ——在。。。之后。比较两字符的ascii码
is in —— 在。。。之中
is not in ——不在。。。中
contains ——包含
does not contain ——不包含

你可能感兴趣的:(AppleScript-字符串)