2012-02-23 80 views
-4

我希望爲撲克手歷史創建一個解析器。我想提取像這些按鈕是誰的信息?解析txt文件的方法

我該如何解決這個問題?以下是一個示例歷史文件:

#Game No : 11460450069 
***** Hand History for Game 11460450069 ***** 
NL Texas Hold'em $1 USD Buy-in Trny:67308896 Level:8 Blinds-Antes(600/1.200 -50) - Wednesday, February 22, 05:48:56 EST 2012 
Table Turbo #2533048 (Real Money) 
Seat 5 is the button 
Total number of players : 2/10 
Seat 5: NAME(2,898) 
Seat 2: NAME(17,102) 
Trny:67308896 Level:8 
Blinds-Antes(600/1.200 -50) 
NAMEposts ante [50] 
NAMEposts ante [50] 
** Dealing down cards ** 
Dealt to NAME[ Th Js ] 
NAME is all-In [2,248] 
NAME calls [1,648] 
** Dealing Flop ** [ 3h, 2d, 9s ] 
** Dealing Turn ** [ Jd ] 
** Dealing River ** [ Ad ] 
NAME shows [ 5s, Kc ]high card Ace. 
NAME shows [ Th, Js ]a pair of Jacks. 
NAME wins 5,796 chips from the main pot with a pair of Jacks. 
NAME finished in 2 place and won $2.55 USD. 
+0

對[ANTLR]來說看起來不錯(http://www.antlr.org/) – 2012-02-23 18:01:25

回答

2

文件格式是文件結構的規範。它們通常是二進制的,但在你的情況下,在許多其他情況下,它們是文本。你需要做的第一件事就是決定文檔的結構,然後像閱讀一樣閱讀它。您也可以使用使這個過程更容易的工具,比如那些基於解析語法規則的工具。我認爲菲利普在他的回答中提到的ANTLR是其中一種工具......