I found a post from 2002 with a replace-script. (see below)
As you will see it replaces every {“-”, “&”} by an {“@”}
What do I have to change to get a Script which replaces a string like {“a”,“b”,“c”,“d”,} by {“z”,“y”,“x”,“w”,}?
Code:
set address_ to "somescripter&macscripter.net"
set replaceWith to "@"
set badCharacters to {"-", "&"}
repeat with thisChar in badCharacters
try
set AppleScript's text item delimiters to thisChar
set fixinIt to text items of address_
set AppleScript's text item delimiters to replaceWith
set fixed_ to fixinIt as string
set AppleScript's text item delimiters to {""}
on error
set AppleScript's text item delimiters to {""}
end try
set address_ to fixed_
end repeat
display dialog address_
Here’s one purely applescript way. You’ll have to pre-define every possible conversion, including capitals. You’ll find that it will slow down quickly with every conversion pair you add, so it’s not the best method for large lists of conversions. There are other ways, like using grep or some other pattern matching in shell or perl commands which would handle capitals automatically… but I have not the experience to help you with those.
set searchString to "The quick brown fox jumped over the lazy dog."
set initReplaces to {{"a", "z"}, {"b", "y"}, {"c", "x"}, {"d", "w"}}
set resultString to ""
repeat with tempItem in (text items of searchString)
set appendChar to tempItem
repeat with tempReplace in initReplaces
set {repKey, repValue} to tempReplace
if (repKey as string) is (tempItem as string) then
set appendChar to repValue
end if
end repeat
set resultString to (resultString & appendChar)
end repeat
display dialog resultString