user3263472
user3263472

Reputation: 11

How to remove text when pasting

I often copy and paste from iBook for personal note taking. How do I create a script that will automatically remove the words "Excerpt From" and all the words following that text whenever I paste in any application?

Upvotes: 0

Views: 318

Answers (1)

CRGreen
CRGreen

Reputation: 3444

You'd have to run the script before you paste, and it might look something like this:

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

--given text on clipboard like "1234------Excerpt From 0987654" you'd end up with "1234------"

Upvotes: 1

Related Questions