RE: Parsing text from a string
RE: Parsing text from a string
- Subject: RE: Parsing text from a string
- From: "Grimm, Kenneth" <email@hidden>
- Date: Wed, 16 Mar 2005 21:08:08 -0500
Why does this not work? I thought about just testing to see if the word
started with "[". So first thing was to get words to test, but when I did
this:
set testString to "Have a [nice] [day]"
set Applescript's text item delimiters to space
return words of testString
I get this result:
--> {"Have","a","nice","day"}
I was expecting:
--> {"Have","a","[nice]","[day]"}
What gives? The square brackets are effectively ignored, regardless of tid's
setting. I tried several variations of code, all with same result.
Now I'm all confused...
Ken
> ----------
> From:
> applescript-users-bounces+kgrimm=email@hidden on
> behalf of Marc K. Myers
> Sent: Wednesday, March 16, 2005 7:00 PM
> To: email@hidden
> Subject: Re: Parsing text from a string
>
> On Mar 16, 2005, at 3:01 PM, Todd Geist <email@hidden>
> wrote:
> > Hello again.
> >
> > I am just full of questions today :>)
> >
> > If I have the string "Have a [Nice] [Day]"
> >
> > I want what is in the first set of brackets "Nice". The brackets will
> > always be somewhere in the string and I want what is in side of them.
> >
> > Thanks so much for all your help?
>
> set theText to "Have a [Nice] [Day]"
> set {od, AppleScript's text item delimiters} to ¬
> {AppleScript's text item delimiters, "]"}
> set x to text items of theText
> set AppleScript's text item delimiters to "["
> set z to ""
> repeat with anItem in x
> set y to text items of anItem
> if (count of y) > 1 then
> set z to last item of y
> exit repeat
> end if
> end repeat
> set AppleScript's text item delimiters to od
> z
> --> "Nice"
>
> Marc [3/16/05 7:59:36 PM]
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> rdtimes.com
>
> This email sent to email@hidden
>
>
_______________________________________________
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