Re: text to list
Re: text to list
- Subject: Re: text to list
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 01 Dec 2002 10:50:26 -0800
On 12/1/02 9:20 AM, "Michelle Steiner" <email@hidden> wrote:
>
If you're trying to remove the zeros, then it's just a bit more complex:
>
>
set text item delimiters to {"0"}
>
set foo to text items of "102030405060708090"
>
set text item delimiters to {""}
>
foo
>
--> {"1", "2", "3", "4", "5", "6", "7", "8", "9", ""}
>
>
A little touch up is necessary to remove that final empty string,
>
caused by that final zero.
>
>
set theString to "102030405060708090000"
>
>
repeat while the last character of theString is "0"
>
set theString to text 1 through -2 of theString
>
end repeat
Hmmm. None of us have thought about "real" zeroes appearing as "000"; i.e..
a 'real' zero appearing between other integers. If John has any of those,
all our methods will produce {"8", "9", "", "1", "2"} etc. You can get rid
of all of those by first checking for "00" as follows. It will take care of
any final sequence of zeroes as well, plus any longer set such as
"100000002":
set {oldTIDs, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, {"00"}}
try
set a to text items of theText
on error
set a to my LargeTidsList(theText, "00")
end try
set AppleScript's text item delimiters to {""}
set theText to b as string
set AppleScript's text item delimiters to {"0"}
try
set a to text items of theText
on error
set a to my LargeTidsList(theText, "0")
end try
set AppleScript's text item delimiters to oldTids
return a
on LargeTidsList(theText, tid)
--etc., from last post
end LargeTidsList(theText, tid)
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.