Re: what the heck - text manipulation script
Re: what the heck - text manipulation script
- Subject: Re: what the heck - text manipulation script
- From: "Stockly, Ed" <email@hidden>
- Date: Tue, 18 Jul 2006 11:12:45 -0700
(*
Natalie, The simplest solution is to use applescript's text item delimiters. They can be a bit trick to master, but they work on any mac that runs appleScript.
I'm guessing that this script is manipulating a sports schedule and for home games the "@" isn't there and in other cases the opposing team's name is one word or more than two words (The Los Angeles Angels of Anaheim, for example, although I don't think they'll be playing in October this year).
Here's a couple suggestions:
*)
set AppleScript's text item delimiters to ""
set myText to "OCT 05 @St. Louis" as string
if "@" is in myText then set foundText to words 3 thru 4 of myText as string
if "@" is in myText then set foundText to words 3 thru -1 of myText as string
set AppleScript's text item delimiters to space
set foundText to text item 6 of myText
set foundText to text items 6 thru -1 of myText as string
set AppleScript's text item delimiters to " " --four spaces
set foundText to text item 2 of myText
set foundText to words 1 thru -2 of text item 2 of myText
set AppleScript's text item delimiters to space
set foundText to foundText as string
(*
>>>NL>>>I realize Applescript is seeing it differently. I just don't know how or why and how to override it without doing some "hardwiring" of the variables (ie if x = "St" set x to "@St.") which I don't want to do. I'm trying to keep this script as generic as possible for future use.
You are definitely on the write track. There's no need for Reg Exp or anything beyond pure appleScript.
I would stick to delimiters. Words can be tricky in AppleScript.
HTH,
ES
*)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden