You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Notepad++高级查找替换:为send行添加对应ex编号注释

在Notepad++中批量添加对应编号的说明行

原始文档内容

ex 1 
send power g1 g2 g3 g4 
ex 2 
send power g1 g2 
ex 3 
send power g1 f5 f3
ex 4 
send f5 f2 t5

目标效果

ex 1 
send power g1 g2 g3 g4
this is number `1' 
ex 2
send power g1 g2 
this is number `2'
ex 3 
send power g1 f5 f3
this is number `3'
ex 4 
send f5 f2 t5
this is number `4'

实现步骤

  1. 打开Notepad++并加载目标文档。
  2. 按下快捷键Ctrl+H打开替换窗口(也可通过菜单栏「搜索」→「替换」打开)。
  3. 在窗口左下角「搜索模式」中选择「正则表达式」。
  4. 在「查找内容」输入框粘贴以下正则表达式:
    (ex (\d+)\r?\n)(send.*?)\r?\n
    
  5. 在「替换为」输入框粘贴以下内容:
    $1$3\r\nthis is number `$2' \r\n
    
  6. 点击「全部替换」按钮,即可完成批量修改。

正则逻辑说明

  • (ex (\d+)\r?\n):捕获以ex开头的行,其中(\d+)提取出编号数字,\r?\n兼容Windows(\r\n)和Unix(\n)的换行格式。
  • (send.*?)\r?\n:捕获以send开头的行,.*?非贪婪匹配行内内容,避免跨多行匹配。
  • 替换内容里的$1对应捕获的ex行,$3对应捕获的send行,$2对应提取出的编号数字,以此实现对应编号的说明行插入。

内容的提问来源于stack exchange,提问作者a_todd12

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 22:24:33