2017-07-30 56 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