我有一个这样的示例数据:
line1
line2
line3
line4
line5
我想在每一行 ODD 后添加一个点,如下所示:
line1 .
line2
line3 .
line4
line5 .
然后,我想在 EVEN 行之前添加一个点,如下所示:
line 1
. line 2
line 3
. line 4
line 5
答案1
- Ctrl+H
- 找什么:
^(.+)(\R)(.+\R)?
- 用。。。来代替:
$1 .$2. $3
- 查看 环绕
- 查看 正则表达式
- 取消选中
. matches newline
- Replace all
解释:
^ # beginning of line
(.+) # group 1, 1 or more any character but newline
(\R) # group 2, any kind of linebreak (i.e. \r, \n, \r\n)
(.+\R)? # group 3, optional, 1 or more any character and a linebreak
替代品:
$1 .$2. $3 # content of group 1, a space, a dot, content of group 2, a dot, a space, content of group 3
截图(之前):
截图(之后):