Ms word AppleScript:如何删除Microsoft Word for Mac中的所有英文段落?

Ms word AppleScript:如何删除Microsoft Word for Mac中的所有英文段落?,ms-word,applescript,Ms Word,Applescript,我有这样一份文件: English English English English 中文中文中文中文中文 English English English English 中文中文中文中文 英文段落和中文段落按此顺序依次显示 那么,我有没有办法把所有的英文段落都记下来 我知道grep,我知道如何使用regex和类似awksed。。但我想在Microsoft Word中执行此操作,因此: 如何用AppleScript解决这个问题 谢谢大家 这不是很漂亮,但它应该能完成任务 property

我有这样一份文件:

English English English English

中文中文中文中文中文

English English English English

中文中文中文中文
英文段落和中文段落按此顺序依次显示

那么,我有没有办法把所有的英文段落都记下来

我知道
grep
,我知道如何使用
regex
和类似
awk
sed
。。但我想在Microsoft Word中执行此操作,因此:

如何用AppleScript解决这个问题


谢谢大家

这不是很漂亮,但它应该能完成任务

property english : "abcdefghijklmnopqrstuvwxyz"
set deleteMe to {}

tell application "Microsoft Word"
    tell active document
        set pCount to count of paragraphs
        repeat with i from 1 to pCount
            set cCount to count of characters in characters of paragraph i
            repeat with j from 1 to cCount
                tell paragraph i
                    if content of character j is in english then
                        set end of deleteMe to i
                        exit repeat
                    end if
                end tell
            end repeat
        end repeat

        set dCount to -(count of deleteMe)
        repeat with k from -1 to dCount by -1
            set content of text object of paragraph (item k of deleteMe) to "" -- delete paragraph
        end repeat
    end tell
end tell