如何用每行变化的值替换出现

时间:2017-12-03 14:02:32

标签: regex notepad++

从研究中我发现如何用常量值替换一个事件,但是如何用每行中前一个变量的值替换变量的值,其中变量的值在记事本++中的每一行都不断变化。

例如:

line1: a=sddfs, b=fegsdfs, c=ewresfs  
line2: a=oreot, b=hdrtytggs, c=fgdfgsdf 

应改为

line1: a=sddfs, b=sddfs, c=ewresfs  
line2: a=oreot, b=oreot, c=fgdfgsdf 

,即每行的b值应改为该行中a的对应值。

1 个答案:

答案 0 :(得分:0)

假设line1:line2:不属于文件

  • 控制 + ħ
  • 找到:^(a=(\w+), b=)\w+
  • 替换为:$1$2
  • 检查环绕
  • 检查正则表达式
  • 全部替换

<强>解释

^           : begining of line
(           : start group 1
  a=        : literally a=
  (         : start group 2
    \w+     : 1 or more word characters (the value after a=)
  )         : end group 2
  , b=      : literally
)           : end group 1
\w+         : 1 or more word characters (the value after b=)

<强>替换

$1      : the value of group 1
$2      : the value of group 2

给定示例的结果:

a=sddfs, b=sddfs, c=ewresfs  
a=oreot, b=oreot, c=fgdfgsdf 
相关问题