• 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
replacing text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

replacing text


  • Subject: replacing text
  • From: Michael Glasser <email@hidden>
  • Date: Mon, 3 Mar 2003 21:30:49 -0700

The apple web site has a script for replacing a word in text, for example "I like bananas" could become "I like apples"... but their example only works if you know the case of the text in question. I have been struggling with making a function that would allow me to check a set of words and change the text... for example see the following code... I want it to display "I WANT TO SEE A big PENGUIN"... but I can not get the function replace_words to work...

any ideas on a working example of

----------------------------------------------

set the_list to {"penguin","turtle","owl")
set the_text to "I WANT TO SEE A PENGUIN"

repeat with loop from 1 to number of items in the_list
set the_word to item loop of the_list
set the_text to replace_words (the_text,the_word,"big " & the_word)
end repeat

display dialog the_text -- answer should be "I WANT TO SEE A big PENGUIN" (I do not expect the replacement text to guess the case)

on replace_words (full_text, search_string, replacement_string)
do nifty magic that just works
return magic_text
end
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: replacing text - solved
      • From: Michael Glasser <email@hidden>
    • Re: replacing text
      • From: David Hood <email@hidden>
  • Prev by Date: Unzipping Files
  • Next by Date: Re: myLoop: getting subject of messages in Mail.app
  • Previous by thread: Re: Unzipping Files
  • Next by thread: Re: replacing text
  • Index(es):
    • Date
    • Thread