2017-07-30 39 views
-2

所以我有一些代码,以改革(1000线),我想从这个记事本++如何交换两个如果再声明

if $one=0 and $two=32 then $dist=1 
if $one=0 and $two=15 then $dist=2 
if $one=0 and $two=19 then $dist=3 

去这个

if $one=0 and $dist=1 then $two=32 
if $one=0 and $dist=2 then $two=15 
if $one=0 and $dist=3 then $two=19 

中的几句话用$ dist和它的值交换$ 2和它的值。

它可以发生与记事本++的正则表达式吗?欢呼声

+0

我没有downvote你,但你有没有尝试过的东西没有? –

+0

是------------如果([^] +)和([^] +)那么([^] +) – asiawatcher

+1

为什么downvote?这个问题很愚蠢吗? – asiawatcher

回答

1
  • 按Ctrl + H^
  • 查找内容:(\$two=\d+)(then)(\$dist=\d+)
  • 替换:$3$2$1
  • 更换所有

说明:

(\$two=\d+)  : group 1, contains "$two=1 or more digits" 
(\s+then\s+) : group 2, literally "then" surrounded by spaces 
(\$dist=\d+) : group 3, contains "$dist=1 or more digits" 

\$必须转义,因为它是一个正则表达式中的特殊字符。

更换:

$3$2$1 : group 3 group 2 group 1 

结果为给定的例子:

if $one=0 and $dist=1 then $two=32 
if $one=0 and $dist=2 then $two=15 
if $one=0 and $dist=3 then $two=19