2010-11-02 21 views
0

基本上撲克客戶端程序生成文件(txt)作爲handhistory日誌,我想要一些程序自動編輯handhistory,只需在前面添加「$」符號數字然後在新目錄中生成新的txt文件,這樣我就可以在另一個軟件中分析新創建的文件。用循環批量替換程序生成的txt文件中的單詞

下面

是一個樣本handhistory日誌:

Full Tilt Poker Game #23461961057: Table .COM Play 463 (deep) - 3000/6000 - No Limit Hold'em - 15:16:29 ET - 2010/08/29 
Seat 2: Player1 (795,425) 
Seat 5: Player2 (1,200,000) 
Player1 posts the small blind of 3,000 
Player2 posts the big blind of 6,000 
The button is in seat #2 
**** HOLE CARDS **** 
Dealt to Player1 [Ac 4c] 
Player1 raises to 12,000 
Player2 raises to 687,000 
Player1 raises to 795,425, and is all in 
Player2 folds 
Player2 adds 687,000 
Uncalled bet of 108,425 returned to Player1 
Player1 mucks 
Player1 wins the pot (1,374,000) 
*** SUMMARY *** 
Total pot 1,374,000 | Rake 0 
Seat 2: Player1 (small blind) collected (1,374,000), mucked 
Seat 5: Player2 (big blind) folded before the Flop 
下面

是處理過的文件,我想:

Full Tilt Poker Game #23461961057: Table .COM 463 (deep) - $3000/$6000 - No Limit Hold'em - 15:16:29 ET - 2010/08/29 
Seat 2: Player1 ($795,425) 
Seat 5: Player2 ($1,200,000) 
Player1 posts the small blind of $3,000 
Player2 posts the big blind of $6,000 
The button is in seat #2 
*** HOLE CARDS *** 
Dealt to Player1 [Ac 4c] 
Player1 raises to $12,000 
Player2 raises to $687,000 
Player1 raises to $795,425, and is all in 
Player2 folds 
Player2 adds $687,000 
Uncalled bet of $108,425 returned to Player1 
Player1 mucks 
Player1 wins the pot ($1,374,000) 
*** SUMMARY *** 
Total pot $1,374,000 | Rake $0 
Seat 2: Player1 (small blind) collected ($1,374,000), mucked 
Seat 5: Player2 (big blind) folded before the Flop 

我做了一些研究,並在AutoHotkey想出了爲做事的結果像這樣,但在編程方面我是一個新手,正當我輸入這個時,正則表達式會強姦我的大腦。你能幫忙的話,我會很高興。

回答

1
(?<!Seat)(?<![a-zA-Z#])([0-9]+(?:,[0-9]+)*) 

與$ \ 1

本質更換,這樣做是認爲可以通過不以「#」或字母或座位開始(因爲我注意到,逗號separted所有號碼在字符串「Full Tilt Poker Game#23461961057」和「Seat 2」中,您沒有添加$)。算法是貪婪的,所以應該考慮到模式在用逗號分隔的數字中的每個逗號之後重複的事實。

如果您使用JavaScript,很遺憾,您不能使用後面的外觀。

+0

讓我想起舊電腦怪胎的笑話......「嘿雷吉,看看你身後。」 「那是什麼?」 「嗯,這當然不是JavaScript,哈哈哈!」 – ewall 2010-11-02 17:47:49

+0

(管理層想爲最後一個笑話道歉,並向您保證,作者*將會*回到他的藥物上以防止進一步爆發。) – ewall 2010-11-02 17:49:27

+0

好吧,現在讓代碼看起來不像現有語言並不難是嗎? 〜_ ^ – Neil 2010-11-03 09:44:56

相關問題