• 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: Replacing in TextEdit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replacing in TextEdit


  • Subject: Re: Replacing in TextEdit
  • From: Paul Robinson <email@hidden>
  • Date: Sat, 25 Sep 2004 14:22:13 +0100

Ummm! Also my script won't handle upper and lower case - if that's important.

P.

On 25 Sep 2004, at 13:38, Paul Robinson wrote:

Sorry - meant to send this to the list.

P.

Begin forwarded message:

From: Paul Robinson <email@hidden>
Date: 25 September 2004 13:36:14 BST
To: "Vince E." <email@hidden>
Cc: Paul Robinson <email@hidden>
Subject: Re: Replacing in TextEdit

Well, you could try
--code begins
tell application "TextEdit"
	set test_str to text of document 1
	set AppleScript's text item delimiters to "open"
	set test_items to text items of test_str
	set AppleScript's text item delimiters to "close"
	set final_str to test_items as text
	set text of document 1 to final_str
end tell
--code ends

This works for plain text, and replaces all instances of 'open' with 'close'. It will also work for rtf files, but you would have to have a loop that works its way through each attribute run, saves text font, size and colour. Then manipulates the text as above, and adds back in the formatting before displaying the new text. Might be slow for long pieces of text with frequent format changes.

HTH
P.

On 25 Sep 2004, at 10:16, Vince E. wrote:

That's easy! - But what if the piece of text you are going to replace is neither a word nor a character or a paragraph?
What if it is a part of a word like the 'bag' of 'handbag' you want to change into 'foot'? - just for example!


I want the user to be able to type any text into a text field he/she wants to be replaced
so I need a more general specification than word, character or paragraph but I just don't know how to name it


Thanx Vince

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


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:
email@hidden


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
References: 
 >Fwd: Replacing in TextEdit (From: Paul Robinson <email@hidden>)

  • Prev by Date: Re: Replacing in TextEdit
  • Next by Date: Re: activate only one window
  • Previous by thread: Fwd: Replacing in TextEdit
  • Next by thread: Re: Replacing in TextEdit
  • Index(es):
    • Date
    • Thread