• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Extract words.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Script Debugger 3 and AppleScript Studio
      • From: Jason Bourque <email@hidden>
References: 
 >Extract words. (From: "Ruby Madraswala" <email@hidden>)

  • Prev by Date: Re: Passing calls to an AS app via shell?
  • Next by Date: Re: Extract words.
  • Previous by thread: Extract words.
  • Next by thread: Script Debugger 3 and AppleScript Studio
  • Index(es):
    • Date
    • Thread