区分大小写搜索并用 AppleScript 替换
Case Sensitive Search and Replace with AppleScript
我正在尝试编写一个小脚本来用 AppleScript 替换文本中的字符。
很遗憾,AppleScript 无法识别大小写。
知道如何考虑大小写吗?
set input to "ApeAlexaBobBorder"
set the clipboard to replaceText(input as string)
on replaceText(textString)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to "A"
set textString to text items of textString
set AppleScript's text item delimiters to ", A"
set textString to "" & textString
set AppleScript's text item delimiters to prevTIDs
return textString
end replaceText
您可以在 considering
语句中对比较进行分组,例如:
considering case
set the clipboard to replaceText(input as string)
end considering
有关详细信息,请参阅 AppleScript Language Guide。
我正在尝试编写一个小脚本来用 AppleScript 替换文本中的字符。
很遗憾,AppleScript 无法识别大小写。
知道如何考虑大小写吗?
set input to "ApeAlexaBobBorder"
set the clipboard to replaceText(input as string)
on replaceText(textString)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to "A"
set textString to text items of textString
set AppleScript's text item delimiters to ", A"
set textString to "" & textString
set AppleScript's text item delimiters to prevTIDs
return textString
end replaceText
您可以在 considering
语句中对比较进行分组,例如:
considering case
set the clipboard to replaceText(input as string)
end considering
有关详细信息,请参阅 AppleScript Language Guide。