Ryannnnnmmm
Ryannnnnmmm

Reputation: 25

Split query into two arguments using delimiter " " (space) - applescript

I am trying to work out how I am able to split the query entered on run in applescript into two separate variables able to be operated on.

Example:

{query} = bob jane

variable1 = bob

variable2 = jane

I was looking into doing this as a wordlist but have been unsuccessful as it separates the query by other symbols apart from " " [space].

I am sorry, I am not very good with applescript and am very confused as to how to go about doing this. Thankyou for any help.

Upvotes: 1

Views: 1270

Answers (1)

CJK
CJK

Reputation: 6092

set input to "bob jane"
set the text item delimiters to space
set {var1, var2} to {text item 1, text item 2} of the input

var1 will now be set to "bob", and var2 will be set to "jane".


Added 2020-10-26:

Alternatively:

set input to "bob jane"
set {var1, var2} to the input's words

Upvotes: 1

Related Questions