• 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: Weeding out words
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weeding out words


  • Subject: Re: Weeding out words
  • From: Marc Myers <email@hidden>
  • Date: Fri, 9 Feb 2007 17:59:36 -0500

On Feb 9, 2007, at 3:00 PM, email@hidden wrote:
set TitleAns to "My Collection box set asset boxy dog box
collection is here" -- some example text returned in a user dialog
set Offenders to {"collection", "box", "set", "boxset"} -- words
which need to be stripped if the user entered them by mistake.

It would be a whole lot easier to do with with a scriptable text editor than with straight AppleScript. I use Tex-Edit Plus for such jobs. Why reinvent the wheel?


set TitleAns to "My Collection box set asset boxy dog box collection is here"
set Offenders to {"collection", "box", "set", "boxset"}
tell application "Tex-Edit Plus"
set contents of window 1 to TitleAns
repeat with i in Offenders
replace window 1 looking for i replacing with ¬
"" whole words matching true ¬
without cases matching
end repeat
set i to 1 -- so the result won't be 0 before the repeat
repeat until the result is 0 -- clean up multiple spaces
replace window 1 looking for " " replacing with " "
end repeat
set x to contents of window 1
end tell


"My asset boxy dog is here"
--
Dr. Gillian Taylor: Are you sure you won't change your mind?
Mr. Spock: Is there something wrong with the one I have?
  -- Star Trek IV

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden
  • Prev by Date: Re: Weeding out words
  • Next by Date: Re: Getting started with XML?
  • Previous by thread: Re: Weeding out words
  • Next by thread: I was going about it all wrong
  • Index(es):
    • Date
    • Thread