re: Scriptable Search-and-Replace Utilities
re: Scriptable Search-and-Replace Utilities
- Subject: re: Scriptable Search-and-Replace Utilities
- From: Kirk Kerekes <email@hidden>
- Date: Mon, 14 Jan 2002 15:32:36 -0600
on 01/14/02 01:43 PM, email@hidden at
email@hidden may have written:
>
Hello.
>
>
I am searching for a search-and-replace utility that is AppleScript-able.
>
I've begun testing Text Machine, but I'd like to have some outside opinions
>
of it. I'd also like to know if there are other scriptable s-and-r
>
utilities and what users think of them.
Consider AppleScript itself. The replace_chars routine offered in the
Essential Subroutines section of the AppleScript Guidebook:
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
-- is remarkably quick due to its use of the highly optimized Text Item
Delimiters function, and gains additional effective speed by not having to
use inter-application communication to do the work. I use it all the time
for fairly heavy-duty tasks like automated web-page creation for database
publishing. I have yet to break it.
For more control, you can easily create custom utilities using the TID, the
offset function, and AppleScripts "word" reference.