2013-03-07 65 views
0

我試圖找到行鞠躬然後用專業更換專業(ASPEED 700)記事本+ +定期查找和替換

用記事本+ +正則表達式

(item (name 767) (Index 567) (Image "wea098") (Action 10 2) (class weapon bow) (code 1 2 2 2) (country 2) (level 56) (wear 1) (limit archer 56) (range 176) (buy 0) (sell 1) (endurance 30) (maxprotect 150) (specialty (Str 1) (Dex 4) (Attack 172 232) (hp 150) (mp 50) (hit 72))) 

(item (name 770) (Index 570) (Image "wea101") (Action 10 2) (class weapon wand) (code 1 2 1 3) (country 2) (level 56) (wear 1) (limit mage 56) (range 18) (buy 0) (sell 1) (endurance 30) (maxprotect 150) (specialty (aspeed 1000) (Int 5) (Attack 150 160) (Magic 220 300) (mp 250) (hit 64))) 

我試圖

Find What : .*class\s*weapon\s*bow.*specialty[^.] 
Replace With \1 (aspeed 700) 

結果爲:

(aspeed 700) (Str 1) (Dex 4) (Attack 172 232) (hp 150) (mp 50) (hit 72))) 

,我想應該是結果:

(item (name 767) (Index 567) (Image "wea098") (Action 10 2) (class weapon bow) (code 1 2 2 2) (country 2) (level 56) (wear 1) (limit archer 56) (range 176) (buy 0) (sell 1) (endurance 30) (maxprotect 150) (specialty (aspeed 700) (Str 1) (Dex 4) (Attack 172 232) (hp 150) (mp 50) (hit 72))) 

THX

+0

我想你可能需要在整個正則表達式中使用parens才能使它成爲一個組,因此你可以在\ 1中使用它。 – 2013-03-09 01:41:02

回答

1

如果bowspecialty之前經常來,然後用這個:

Find what:  (.*bow.*)(specialty) 
Replace with: $1specialty (aspeed 700) 

如果bowspecialty後曾談到它可能最容易做到這一點與兩個正則表達式,上面這個和這個:

Find what:  (specialty)(.*bow.*) 
Replace with: specialty (aspeed 700)$2 

如果你是硬核,那麼你也許可以結合這兩種正則表達式,我能想到的辦法做到這一點,現在:)

附: Notepad ++的老版本在正則表達式方面存在問題。獲取most recent version(撰寫本文時爲6.3)以確保您沒有問題。