以下是一个示例代码,演示了如何使用Bbedit删除除指定模式之外的所有内容:
tell application "BBEdit"
-- 获取当前文档的内容
set docContent to contents of text document 1
-- 设置要保留的模式
set pattern to "这个模式"
-- 将内容拆分成行
set lines to paragraphs of docContent
-- 创建一个新的空白文档
set newDoc to make new text document
-- 遍历每一行内容
repeat with i from 1 to count of lines
set lineContent to item i of lines
-- 检查当前行是否匹配指定的模式
if lineContent contains pattern then
-- 将匹配的行添加到新文档中
tell newDoc
make new text at end of text with data lineContent & return
end tell
end if
end repeat
-- 关闭原始文档
close text document 1
-- 显示新文档
activate
end tell
请注意,这只是一个示例,你需要根据自己的需求进行修改和适应。你可以根据实际情况更改“这个模式”以及需要处理的文档类型和位置。