1 回答

TA貢獻1834條經驗 獲得超8個贊
試試這個:
func main() {
file, rah := ioutil.ReadFile("HH20201223.txt")
if rah != nil {
log.Fatal(rah)
}
str := string(file)
slicedHands := strings.SplitAfter(str, "\n\n\n") //splits the string after two new lines, hands is a slice of strings
mapHand := handMap{}
for i := range slicedHands {
matchHoldem, _ := regexp.MatchString(".+Hold'em", slicedHands[i]) //This line matches the regex
matchStake, _ := regexp.MatchString(".+(\\$0\\.05\\/\\$0\\.10)", slicedHands[i])
h := handkey{}
if matchHoldem {
h.game = "No Limit Hold'em"
}
if matchStake {
h.stake = "10NL"
}
mapHand[i] = h
}
}
- 1 回答
- 0 關注
- 104 瀏覽
添加回答
舉報