Text item delimiters are what you are looking for, for example:
set myString to "MyData1|MyData2"
set {myVar1, myVar2} to splitString(myString)
to splitString(someString)
try
set tempTID to AppleScript's text item delimiters -- save current delimiters
set AppleScript's text item delimiters to "|"
set pieces to text items of someString -- split the string
set AppleScript's text item delimiters to tempTID -- restore old delimiters
set firstPart to item 1 of pieces
set secondPart to item 2 of pieces
on error errmess -- delimiter not found
log errmess
return {firstPart, ""} -- empty string for missing item
end try
return {firstPart, secondPart}
end splitString
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags: