Re: TID & text items issue
Re: TID & text items issue
- Subject: Re: TID & text items issue
- From: Christopher Nebel <email@hidden>
- Date: Tue, 23 Oct 2012 15:50:19 -0700
On Oct 22, 2012, at 3:38 PM, John C. Welch <email@hidden> wrote:
> Okay, so I swear this used to work better, or maybe I'm crazy.
>
> I have a string:
>
> " 8 0 0xffffff7f81592000 0x41000 0x41000
> com.apple.kec.corecrypto (1.0) "
>
> I want to strip out the stuff that isn't spaces. Should be easy. Set TIDs
> to " ", and get every text item. The problem is, I get a listing for the
> delimiters too, and then I'm in repeat hell.
>
> I could SWEAR this used to work better, as in the delimiters didn't get in
> the list, just the stuff that wasn't delimiters.
>
> Is there a way to deal with this that doesn't require brute forcing via
> repeat loops?
You're not getting items for the delimiters themselves, you're getting items in between the spaces, which is what you asked for. "Delimiters" in AppleScript are taken literally, with no implied "string of one or more", so in a string of multiple spaces, you get an empty item in between each pair of spaces.
Using "words" to break up strings like this is not generally advisable, since the definition of a "word" is rather subtle and can change depending on user locale settings.
Shane's trick of using multiple delimiters, each being a different-length string of spaces, is rather clever and works well (if somewhat verbosely), though it doesn't work prior to Snow Leopard, if that's of concern to you. (Respecting multiple delimiters was, by the way, the second-oldest bug fixed in Snow Leopard. The oldest one had to do with some specific text-to-speech mispronunciations.)
--Chris N.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden