Re: Extract words.
Re: Extract words.
- Subject: Re: Extract words.
- From: Mr Tea <email@hidden>
- Date: Fri, 08 Oct 2004 17:07:19 +0100
This from Ruby Madraswala - dated 8/10/04 3ยท27 pm:
> Just needs some guidance to write a script to extract all words between "\"
> and "|" from a text file.
Hi, Ruby.
There's a slight awkwardness here because the backslash is an escape
character in AppleScript strings (telling AS to ignore the next character),
so you need to get round this by 'double escaping', which involves using two
backslashes. AS will automatically insert these, so that if you read in the
text from a file the result will look like this...
"\\According| to knowledge base papers, they will \\work| if you bugger
around with the parts a little and open them \\manually|"
The following code will give you a return de-limited list of words as a
string, ready for writing to file.
set txt to "\\According| to knowledge base papers, they will \\work| if you
bugger around with the parts a little and open them \\manually|."
set wrds to every word of txt
set savewrd to false
set keychars to {"\\", "|"}
set wrdlst to ""
repeat with i from 1 to count wrds
set wrd to item i of wrds
if wrd is "\\" then set savewrd to true
if wrd is "|" then set savewrd to false
if savewrd then
if wrd is not in keychars then set wrdlst to wrdlst & wrd & return
end if
end repeat
wrdlst --> "According
work
manually
"
HTH
Nick
pp Mr Tea
--
_______________________________________________
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