Thanks Mark,
Your code
worked fine. I made few changes and it picks up all text before the first “\”.
I checked the text there are no “\” or “|” within that portion of text. Am I missing
something out.
Set wfile
to hotolfer & num
Set xfile
to hotfolder & num & “x”
set theText to to read file wfile from 1
set AppleScript's text item delimiters to {"\\"}
set wordList to text items of theText
set AppleScript's text item delimiters to {""}
if item 1 of wordList is "" then
set wordList to rest of
wordList
end if
repeat with
a from
1 to count of wordList
set AppleScript's text item delimiters to {"|"}
set item a of wordList to item 1 of
text items of item a of wordList
set AppleScript's text item delimiters to {""}
end repeat
set
counter to number of items of wordlist
set
outfile to open for access file xfile with write permission
repeat
a from 1 to counter
write
item a of wordlist & return to outfile
end
repeat
Ruby
-----Original
Message-----
From:
applescript-users-bounces+rubym=email@hidden
[mailto:applescript-users-bounces+rubym=email@hidden]On Behalf Of Mark Butcher
Sent: Friday, October 08, 2004
11:05 AM
To: AppleScript Users
Subject: Re: Extract words.
Ruby
The backslash
is a reserved character, and used for quotes(\"), returns (\r), tabs (\t),
linefeeds (\n) and other backslashes (\\) in a text string. Hence in the script
below there are double backslashes:
set theText to "\\According| to knowledge base
papers, they will \\work| if you bugger around with the parts a little and open
them \\manually|."
set AppleScript's text item delimiters to {"\\"}
set wordList to text items of theText
set AppleScript's text item delimiters to {""}
if item 1 of wordList is "" then
set wordList to rest of
wordList
end if
repeat with
a from
1 to count of wordList
set AppleScript's text item delimiters to {"|"}
set item a of wordList to item 1 of
text items of item a of wordList
set AppleScript's text item delimiters to {""}
end repeat
return wordList
-->
{"According", "work", "manually"}
MarkB
On Oct 8,
2004, at 7:27 AM, Ruby Madraswala wrote:
Hi All
Just needs some guidance to write a script
to extract all words between "\" and "|" from a text file.
Example:
\According| to knowledge base papers, they
will \work| if you bugger around with the parts a little and open them
\manually|.
According
Work
Manually
I have no problem writing the list to a
newfile.
Thanks
Ruby
_______________________________________________
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