Created
May 28, 2020 11:33
-
-
Save mingsai/edab1786486e957c14f7a6583a23e0f6 to your computer and use it in GitHub Desktop.
Applescript: Replace text handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Replaces a substring with another substring | |
(* | |
set my_var to StringsLib's replace_text(some_text, "abc", "def") | |
*) | |
on replace_text(this_text, search_string, replacement_string) | |
set prevTIDs to AppleScript's text item delimiters | |
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 prevTIDs | |
return this_text | |
end replace_text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment