Hi,
Is it possible to have multiple text item delimiters? I thought it would be something like this:
set Applescript's text item delimiters to {":" , "_"}
…but I haven’t gotten that to work.
Thanks 8)
Hi,
Is it possible to have multiple text item delimiters? I thought it would be something like this:
set Applescript's text item delimiters to {":" , "_"}
…but I haven’t gotten that to work.
Thanks 8)
Not possible, as far as I know. In your example, only the first item will be the delimiter. The second one will be ignored.
Yup, that’s exactly what happens. Oh well, I thought there was a way, but I guess not.
Thanks again…
8)
There is a way if you’re getting the text by reading a file. If you have a text path reference to the text file, you can use a line like the following:
set textAsArray to read file textFilePath using delimiter {tab, return}
For multi-item delimiters, I use this routine:
set the_string to "This is a string: with_multiple delimiters."
set the_delims to {":", "_"}
my multi_atid_split(the_string, the_delims)
on multi_atid_split(the_string, the_delims)
set {OLD_delim, temp_delim} to {AppleScript's text item delimiters, "?|?"}
repeat with this_delim in the_delims
my atid(this_delim)
set the_string to text items of the_string
my atid(temp_delim)
set the_string to text items of the_string as string
end repeat
my atid(temp_delim)
set the_string to text items of the_string
my atid(OLD_delim)
return the_string
end multi_atid_split
on atid(the_delim)
set AppleScript's text item delimiters to the_delim
end atid
Jon