How to replace characters in AppleScript

Can somebody tell me if there’s a replace function similar to PHP (str_replace) where you can replace characters? For example, I would like to replace any instance of “Folder1:Folder2:Folder3” to “Folder1/Folder2/Folder3”. Any help would be greatly appreciated.

This article looks like it covers it fairly good - for some reason it keeps coming up in every applescript search I do!
Specifically the Find and replace section.


Also, you can change an AppleScript type path (colons) to POSIX path (slashes) with the ‘POSIX path’ property from standard additions. Something like this:

set item_path to (path to “cusr”) as string – current users home folder
set new_path to (item_path & “SomeFile”)
display dialog new_path buttons {“OK”} default button “OK”
return (POSIX path of new_path) – look at result

Standard additions are built in.