replace - 删除除 Notepad++ 中一行的前 3 个单词之外的所有内容
问题描述
我有一个冗长的文本文档,我想删除除每行前 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
- 检查 环绕
- CHECK 正则表达式
- Replace all
解释:
^ # 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
$
截图(之前):
截图(之后):
推荐阅读
- go - golang 最新稳定版本的 URL
- android - com.google.android.gms.internal.firebase-perf.zzw 上的 NoClassDefFoundError
- python-3.x - 从其他文件加载功能时训练的目的?
- javascript - Node.js:在同一台服务器上运行多个应用程序
- javascript - 如何获取拥有多个孩子的元素?
- windows - FFMPEG - 如何准确获取文件名并在渲染队列的每个输出视频中添加绘图文本
- scala - Spark scala:-在reduceByKey中尝试使用if语句的方式出现错误
- html - Bootstrap - 表单控件输入同一行中的按钮
- sql - 在 SAS (PROC SQL) 中创建串联汇总数据
- android - 如果 windowTranslucentStatus 为 false,则不会调用键盘的 onApplyWindowInsets