Notepad++ 记事本++;:在现有变量行之间添加两行

Notepad++ 记事本++;:在现有变量行之间添加两行,notepad++,Notepad++,我有一个如下所示的要点列表: [-18.551,31.608,12.200] [0.998346,-0.035888,-0.044921,0.000000] [20.000,0.000,40.000] [1.000000,0.000000,0.000000,0.000000] [-18.551,-31.214,12.228] [0.998374,0.035057,-0.044947,0.000000] 61 [-18.551,31.608,12.200] [0.998346,-0.035888

我有一个如下所示的要点列表:

[-18.551,31.608,12.200] [0.998346,-0.035888,-0.044921,0.000000]
[20.000,0.000,40.000] [1.000000,0.000000,0.000000,0.000000]
[-18.551,-31.214,12.228] [0.998374,0.035057,-0.044947,0.000000]
61
[-18.551,31.608,12.200] [0.998346,-0.035888,-0.044921,0.000000]
40
50
[20.000,0.000,40.000] [1.000000,0.000000,0.000000,0.000000]
[-18.551,-31.214,12.228] [0.998374,0.035057,-0.044947,0.000000]
60
51
41
第一行和第三行中的值不同,第二行始终相同。在这三行之前和之后,还列出了变量点。 现在我想添加一些行,使其看起来像这样:

[-18.551,31.608,12.200] [0.998346,-0.035888,-0.044921,0.000000]
[20.000,0.000,40.000] [1.000000,0.000000,0.000000,0.000000]
[-18.551,-31.214,12.228] [0.998374,0.035057,-0.044947,0.000000]
61
[-18.551,31.608,12.200] [0.998346,-0.035888,-0.044921,0.000000]
40
50
[20.000,0.000,40.000] [1.000000,0.000000,0.000000,0.000000]
[-18.551,-31.214,12.228] [0.998374,0.035057,-0.044947,0.000000]
60
51
41
我找到了使用RegEx的三行代码:

\[.*\] \[.*\]\n\[20\.000,0\.000,40\.000\] \[1\.000000,0\.000000,0\.000000,0\.000000\]\n\[.*\] \[.*\]
但我没办法把它换好


谢谢你的帮助

很接近,只需添加捕获组:

  • Ctrl+H
  • 查找内容:
    (\[.\]\[.\]\n)(\[20\.000,0\.000,40\.000\]\[1\.000000,0\.000000,0\.000000,0\.000000\]\n\[.\]\[.\]\n)
  • 替换为:
    61\n${1}40\n50\n${2}60\n51\n41\n
  • 检查环绕
  • 检查正则表达式
  • 全部替换
说明:

(                       # group 1, the first line
    \[.*\] \[.*\]\n
)
(                       # group 2, second and third line
    \[20\.000,0\.000,40\.000\] \[1\.000000,0\.000000,0\.000000,0\.000000\]\n
    \[.*\] \[.*\]\n
)
61\n            # 61 and linefeed
${1}            # content of group 1 (i.e. the first line)
40\n            # 40 and linefeed
50\n            # 50 and linefeed
${2}            # content of group 2, line 3 and 3
60\n            # 60 and linefeed
51\n            # 51 and linefeed
41\n            # 41 and linefeed
61
[-18.551,31.608,12.200] [0.998346,-0.035888,-0.044921,0.000000]
40
50
[20.000,0.000,40.000] [1.000000,0.000000,0.000000,0.000000]
[-18.551,-31.214,12.228] [0.998374,0.035057,-0.044947,0.000000]
60
51
41
更换:

(                       # group 1, the first line
    \[.*\] \[.*\]\n
)
(                       # group 2, second and third line
    \[20\.000,0\.000,40\.000\] \[1\.000000,0\.000000,0\.000000,0\.000000\]\n
    \[.*\] \[.*\]\n
)
61\n            # 61 and linefeed
${1}            # content of group 1 (i.e. the first line)
40\n            # 40 and linefeed
50\n            # 50 and linefeed
${2}            # content of group 2, line 3 and 3
60\n            # 60 and linefeed
51\n            # 51 and linefeed
41\n            # 41 and linefeed
61
[-18.551,31.608,12.200] [0.998346,-0.035888,-0.044921,0.000000]
40
50
[20.000,0.000,40.000] [1.000000,0.000000,0.000000,0.000000]
[-18.551,-31.214,12.228] [0.998374,0.035057,-0.044947,0.000000]
60
51
41
给定示例的结果:

(                       # group 1, the first line
    \[.*\] \[.*\]\n
)
(                       # group 2, second and third line
    \[20\.000,0\.000,40\.000\] \[1\.000000,0\.000000,0\.000000,0\.000000\]\n
    \[.*\] \[.*\]\n
)
61\n            # 61 and linefeed
${1}            # content of group 1 (i.e. the first line)
40\n            # 40 and linefeed
50\n            # 50 and linefeed
${2}            # content of group 2, line 3 and 3
60\n            # 60 and linefeed
51\n            # 51 and linefeed
41\n            # 41 and linefeed
61
[-18.551,31.608,12.200] [0.998346,-0.035888,-0.044921,0.000000]
40
50
[20.000,0.000,40.000] [1.000000,0.000000,0.000000,0.000000]
[-18.551,-31.214,12.228] [0.998374,0.035057,-0.044947,0.000000]
60
51
41

值是
61
40
。。。恒定?是的,它们是constant@user12530628:不客气,很高兴有帮助,请随意将答案标记为已接受,