Re: Extract words.
Re: Extract words.
- Subject: Re: Extract words.
- From: Mark Butcher <email@hidden>
- Date: Fri, 8 Oct 2004 08:05:20 -0700
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
_______________________________________________
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