Re: Parsing out words in email subject
Re: Parsing out words in email subject
- Subject: Re: Parsing out words in email subject
- From: "Stockly, Ed" <email@hidden>
- Date: Thu, 28 Jan 2010 15:36:42 -0800
- Thread-topic: Parsing out words in email subject
> set theSubject to "Re: Parsing out words in email subject"
> set theWord to first word of theSubject
> set allButFirst to words 2 thru -1 of theSubject as text
> display dialog allButFirst
>
> will also give you the correct result.
No, that does not give you the correct result
set theSubject to "Re: Parsing out words in email subject"
-->"Re: Parsing out words in email subject"
set theWord to first word of theSubject
-->"Re"
set allButFirst to words 2 thru -1 of theSubject as text
-->"Parsingoutwordsinemailsubject"
> It seems that words work here a little like text items with text item
delimiters set to space.
No, they only work as words. Words don't include punctuation or return
characters. Asking for words of a string of text generates a list of items,
with each item a word from the string.
> But there are some additional subtleties (try quotes),
Yes, that's why in the example I provided I included punctuation to make it
clear that they wouldn't be included when asking for words.
> and the AppleScript Language Guide says: "Because the rules for parsing words
are thus under user control, your scripts should not count on a deterministic
text parsing of words.
Sure, of course. If the intention of the script is to simply strip a "Re:"
from the beginning of the subject, there are better ways to do that than
parsing the words.
set theSubject to "Re: Parsing out words in email subject"
set AppleScript's text item delimiters to {"Re: "}
set theSubject to the rest of text items of theSubject
set AppleScript's text item delimiters to {" "}
set allButFirst to theSubject as text
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:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden