美文网首页
AppleScript-字符串

AppleScript-字符串

作者: 不写昵称 | 来源:发表于2018-07-29 18:04 被阅读0次

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

字符串拼接--用&

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-字符串

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

  • AppleScript-指令

    say作用:让计算机发声 beep作用:让计算机发出‘咚’的声音。 tell作用:将特定的任务交付给Mac中特定的...

  • AppleScript-变量

    规则 变量只能有一个词组成中间不能有空格不能以数字开头允许使用下划线"_"不能使用关键字做变量名,如count关键...

  • AppleScript-方法

    定义方法 on 方法名(参数列表)return 返回值 -- 如果无返回值可不写end 方法名 方法的调用可在定义...

  • AppleScript-异常捕获

    语法: 举例:

  • AppleScript-逻辑语句

    条件语句 举例: 循环语句 语法1:repeat 循环次数 timesend repeat举例: 语法2:repe...

  • AppleScript-文件及路径

    路径格式:硬盘:子路径:子路径如:"Macintosh HD:Users:henry:Desktop:未命名文件夹...

  • AppleScript-运算符

    算数运算符加、减、乘、除、乘方^ &运算符作用:合并字符串、合并数组如 \转义字符字符串中有引号时 字符串要显示“...

  • AppleScript-基本数据类型

    有4种基本数据类型:numer -- 数字String -- 字符串list ---数组record --相当于...

  • Javascript知识点整合

    字符串 单行字符串: ‘字符串’或“字符串” 多行字符串: `多行字符串` 字符串操作: 字符串连接‘+’号 长度...

网友评论

      本文标题:AppleScript-字符串

      本文链接:https://www.haomeiwen.com/subject/pshtvftx.html