Re: Simple character substitution
Re: Simple character substitution
- Subject: Re: Simple character substitution
- From: Mark Butcher <email@hidden>
- Date: Sun, 26 Jun 2005 11:56:59 -0700
On 2005, Jun 26, , at 11:47, Irwin Poche wrote:
I have been using a handler I'd written to do simple string replacements, such as replacing all occurrences of "this" to "that." Its kludgy, but it's been working - up until I try to change a single character to multiple characters.
I now realize that perl would probably be the best way of doing this but how is anything but obvious for the uninitiated (me). From other postings I believe a do shell script with echo and perl are what I probably need.
Use text item delimiters. Have a look in AS documentation for explanation. Here's a handler I use:
on theString, oldText, newText) --returns string
set defaultTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to oldText
set theString to text items of theString
set AppleScript's text item delimiters to newText
set theString to theString as string
set AppleScript's text item delimiters to defaultTID
return theString
end replaceTextInString
"this and that", "this", "that")
MarkB
_______________________________________________
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