RE: Extract words.
RE: Extract words.
- Subject: RE: Extract words.
- From: "Ruby Madraswala" <email@hidden>
- Date: Fri, 8 Oct 2004 12:36:26 -0400
- Thread-topic: Extract words.
Thanks
The text files I have, does have a single "\" and I see that could be a problem. I tried the script, only works if I have two \s.
Ruby
-----Original Message-----
From: Mr Tea [mailto:email@hidden]
Sent: Friday, October 08, 2004 12:07 PM
To: Ruby Madraswala; AS Users
Subject: Re: Extract words.
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