粘贴时如何删除文本

时间:2014-02-02 18:09:43

标签: applescript

我经常从iBook复制并粘贴个人笔记。如何在任何应用程序中粘贴时,如何创建一个自动删除“摘录自”字样以及该文本后面的所有字词的脚本?

1 个答案:

答案 0 :(得分:1)

在粘贴之前,您必须运行脚本,它可能如下所示:

try
    set c to the clipboard as text
    considering case --to match exactly
        set o to offset of "Excerpt From" in c
    end considering
    set the clipboard to (text beginning thru (o - 1) of c)
on error e
    display dialog e
end try

- 在"1234------Excerpt From 0987654"这样的剪贴板上给出文字,你最终会得到"1234------"