将字符串拆分为多个变量AppleScript

时间:2017-02-09 02:55:11

标签: string variables applescript

如何将AppleScript中用户输入的句子转换为每个单词的单独变量。例如,Lorem ipsum dolor sit amet将被空格拆分为不同的变量,例如。 var1 = lorem, var2 = ipsum等等。以下是我到目前为止所提出的内容,但我显然无处可去。

set TestString to "1-2-3-5-8-13-21"
set myArray to my theSplit(TestString, "-")
on theSplit(theString, theDelimiter)
    -- save delimiters to restore old settings
    set oldDelimiters to AppleScript's text item delimiters
    -- set delimiters to delimiter to be used
    set AppleScript's text item delimiters to theDelimiter
    -- create the array
    set theArray to every text item of theString
    -- restore the old setting
    set AppleScript's text item delimiters to oldDelimiters
    -- return the result
    return theArray
end theSplit

1 个答案:

答案 0 :(得分:4)

只需使用'字'关键词。以下是脚本的一个小例子:

create table Cast (
                 ^