notepad++ - 替换记事本++中的每隔一个空行
问题描述
Notepad ++中有没有办法替换所有其他空白行?填充行的数量是随机的,空行的出现也是随机的。
这种差异是否可以通过不均匀的间距进行,或者是否超出了记事本中的表达式范围?
编辑:我正在寻找替换每第二次出现的空行。
例如:-
Bed
Bee
[BLANK A]
Bible
Bible
Bird
Bomb
[BLANK B]
Book
Boss
Bottle
Bowl
Box
[BLANK A]
Boy
Brain
Bridge
Butterfly
Button
Cappuccino
Car
[BLANK B]
Car-race
Carpet
Carrot
Cave
Chair
[BLANK A]
Chess Board
Chief
Child
Chisel
Chocolates
其中 A 和 B 应分别更换。
解决方案
- Ctrl+H
- 找什么:
((?:.+\R)+)(\R)(?:((?:.+\R)+)(\R))?
- 用。。。来代替:
$1[BLANK A]$2(?3$3[BLANK B]$4)
- 检查 环绕
- CHECK 正则表达式
- 取消选中
. matches newline
- Replace all
解释:
( # group 1 (will contain consecutive non blank lines)
(?: # non capture group
.+ # 1 or more any character but newline
\R # any kind of linebreak (i.e. \r, \n, \r\n)
)+ # end group, may appear 1 or more times
) # end group 1
(\R) # group 2, any kind of linebreak (i.e. first blank line)
(?: # non capture group
( # group 3, same pattern as in group 1
(?:
.+
\R
)+
)
(\R) # group 4, any kind of linebreak (i.e. second blank line)
)? # end group, optional
替代品:
$1 # content of group 1 (non blank lines)
[BLANK A] # replacement for first blank line
$2 # content of group 2, (a linebreak)
(?3 # if group 3 exists:
$3 # content of group 3 (non blank lines)
[BLANK B] # replacement for second blank line
$4 # content of group 4, (a linebreak)
) # end condition
屏幕截图(之前):
屏幕截图(之后):
推荐阅读
- python - 百分比回归 - r、python 和 matlab 中的不同结果
- android - 有没有办法捕捉调用的值事件监听器
- android - AppCenter 推送到 Xamarin.Forms Android 无震动
- django - 使用 Django 加入迁移表
- python - 使用 paramiko 执行别名命令
- javascript - 使用 ASP.Net Core SDK 3.0 preview8(Blazor 框架)上传图片
- node.js - nodejs应用程序中的管理面板和用户面板
- shell - crontab 中的启动脚本在重新启动时不起作用
- java - 如何初始化 Cloud Firestore Bean 以在所有包中使用?
- dart - 在 dart 中解析 X509 证书并提取通用名称