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 ——不包含
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容