Re: read a specific word of a text file
Re: read a specific word of a text file
- Subject: Re: read a specific word of a text file
- From: John Stewart <email@hidden>
- Date: Thu, 23 Sep 2004 04:15:50 -0400
On 09/23/04 at +0530 Jasneet Kaur said this
>I need to read a specific word of a text file (in Mac's text editor) and
>then replace it with another word.
>
>(that is, the kind of action we do with the "Replace All" option in notepad
>when using windows)
>
>So could you please help me do that using AppleScript
set txtStr to "The text you want to search" -- Original text
set srchStr to "you" -- the word or words to be replaced
set rplcStr to "I" -- the word or words to replace with
my doRplc(txtStr, srchStr, rplcStr)
--> "The text I want to search"
on doRplc(txtStr, srchStr, rplcStr)
set {oldDelims, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, {srchStr}}
set temp to every text item of txtStr
set AppleScript's text item delimiters to {rplcStr}
set txtStr to temp as text
set AppleScript's text item delimiters to oldDelims
return txtStr
end doRpl
JBS
--
If Barbie is so popular, why do you have to buy her friends?
_______________________________________________
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