• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: text to list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text to list


  • Subject: Re: text to list
  • From: Michelle Steiner <email@hidden>
  • Date: Sun, 1 Dec 2002 10:20:24 -0700

On Sunday, December 1, 2002, at 07:43 AM, John Clark wrote:

Is there anyway I can convert text to a list.

"102030405060708090" to {"1", "2", "3", etc}

If you want every character to be a text item, then it's simple; no need to set text items.

text items of "102030405060708090"
--> {"1", "0", "2", "0", "3", "0", "4", "0", "5", "0", "6", "0", "7", "0", "8", "0", "9", "0"}

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

set text item delimiters to {"0"}
set foo to text items of theString
set text item delimiters to {""}
foo

--> {"1", "2", "3", "4", "5", "6", "7", "8", "9"}

--Michelle

We're not human beings having a spiritual experience.
We're spiritual beings having a human experience.
_______________________________________________
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.

  • Follow-Ups:
    • Re: text to list
      • From: Paul Berkowitz <email@hidden>
References: 
 >text to list (From: John Clark <email@hidden>)

  • Prev by Date: OS X Folder Actions
  • Next by Date: Re: text to list
  • Previous by thread: Re: text to list
  • Next by thread: Re: text to list
  • Index(es):
    • Date
    • Thread