What is wrong with my code. Why does it not replace the string?
display dialog "Divider?" buttons {"\\", ">", ":"} default button 1
set divider to the button returned of the result
tell application "Finder"
set filepath to (get selection as text)
set filepath to replace_chars(filepath, ":", divider)
display dialog filepath
set the clipboard to filepath
end tell
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