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 关注
- 94 浏览
添加回答
举报