在 Notepad++ 中删除除一行的前 3 个单词之外的所有内容

Remove everything except for first 3 words of a line in Notepad++

我有一个冗长的文本文档,我想删除除每行的前 3 个单词之外的所有内容。我已经看到一些已回答的问题,允许您这样做但只保留第一个词。我只是想知道是否可以用前 3 个代替。这是一个例子:

(原创)

hello how are you today
this is just a test
today is a great day

(我想保留的)

hello how are
this is just
today is a
  • Ctrl+H
  • 查找内容:^\w+\h+\w+\h+\w+\K.*$
  • 替换为:LEAVE EMPTY
  • 检查 环绕
  • 检查 正则表达式
  • 全部替换

解释:

^           # beginning of line
    \w+         # 1 or more word character
    \h+         # 1 or more horizontal space
    \w+         # 1 or more word character
    \h+         # 1 or more horizontal space
    \w+         # 1 or more word character
    \K          # forget all we have seen until this position
    .*          # 1 or more any character but newline
$           

屏幕截图(之前):

截图(之后):