gpt4 book ai didi

applescript - AppleScript 有替换功能吗?

转载 作者:行者123 更新时间:2023-12-03 18:32:17 32 4
gpt4 key购买 nike

在 VBA 中,用不同的子字符串替换子字符串非常容易,例如 objMsg.Body = Replace(objMsg.Body, "<Month\", Format(dtDate1, "mmmm"))取代 "<Month>"在电子邮件正文中使用当前月份。我以前见过与此类似的问题,但它们已经有几年的历史了,并且往往有疯狂的解决方法,几乎​​不值得我花时间。

最佳答案

不,但你可以使用这个( source ):

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

用法:
replace_chars(message_string, "string_to_be_replaced", "replacement_string")

(顺便说一句,你现在也可以使用 JavaScript 而不是 AppleScript,搜索“JavaScript for OS X Automation”)

关于applescript - AppleScript 有替换功能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38041852/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com