tôi đang cố gắng sử dụng biểu thức thông thường trong C#:Iteration qua GroupCollection trong C#
Regex reg_gameinfo = new Regex(@"PokerStars Game #(?<HID>[0-9]+):\s+(?:HORSE)? \(?(?<GAME>Hold'em|Razz|7 Card Stud|Omaha|Omaha Hi/Lo|Badugi) (?<LIMIT>No Limit|Limit|Pot Limit),? \(?(?<CURRENCYSIGN>\$|)?(?<SB>[.0-9]+)/\$?(?<BB>[.0-9]+) (?<CURRENCY>.*)\) - (?<DATETIME>.*$)", RegexOptions.Multiline);
Match matchresults = reg_gameinfo.Match(rawtext);
Dictionary<string,string> gameinfo = new Dictionary<string,string>();
if (matchresults.Success)
{
gameinfo.Add("HID", matchresults.Groups["HID"].Value);
gameinfo.Add("GAME", matchresults.Groups["GAME"].Value);
...
}
Tôi có thể lặp qua matchresult.Groups
GroupCollection và thêm cặp khóa-giá trị vào từ điển gameinfo
của tôi?