我有这样的文件:
English English English English
中文中文中文中文中文
English English English English
中文中文中文中文
英文段落和中文段落按此顺序逐一显示。
所以,有没有办法让我 remvoe 所有的英文段落?
我知道grep
我知道如何使用regex
以及类似awk
sed
的内容..但我想在Microsoft Word中执行此操作,因此:< / p>
AppleScript如何解决这个问题?
谢谢大家!
答案 0 :(得分:1)
这不是很漂亮,但它应该完成工作。
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