import re
regex = re.compile(r"Seat (?P<playerseat>[0-9]+): (?P<playername>[.?]+)")
test_str = ("he name of first value, first 17/04/2013 11:30:00 - A:30.0\n\n"
"PokerStars Hand #152844641611: Tournament #1556870024, $0.44+$0.44+$0.12 USD Hold'em No Limit - Level I (25/50) - 2016/05/04 13:15:07 BRT [2016/05/04 12:15:07 ET]\n"
"Table '1556870024 3' 6-max Seat #1 is the button\n"
"Seat 1: vitalijus (500 in chips) \n"
"Seat 2: papoca555 (500 in chips) \n"
"Seat 3: SITBACKNOW (500 in chips) \n"
"Seat 4: hackerpex (500 in chips) \n"
"Seat 5: vovan189 (500 in chips) \n"
"Seat 6: DiMers80 (500 in chips) \n"
"vitalijus: posts the ante 10\n"
"papoca555: posts the ante 10\n"
"SITBACKNOW: posts the ante 10\n"
"hackerpex: posts the ante 10\n"
"vovan189: posts the ante 10 \n"
"DiMers80: posts the ante 10\n"
"papoca555: posts small blind 25\n"
"SITBACKNOW: posts big blind 50\n"
"*** HOLE CARDS ***\n"
"Dealt to hackerpex [7h 6h]\n"
"hackerpex: folds \n"
"vovan189: calls 50\n"
"DiMers80: raises 440 to 490 and is all-in\n"
"vitalijus: folds \n"
"papoca555: folds \n"
"SITBACKNOW: calls 440 and is all-in\n"
"vovan189: calls 440 and is all-in\n"
"*** FLOP *** [5c 2c 3s]\n"
"*** TURN *** [5c 2c 3s] [Ah]\n"
"*** RIVER *** [5c 2c 3s Ah] [4s]\n"
"*** SHOW DOWN ***\n"
"SITBACKNOW: shows [Ks Tc] (a straight, Ace to Five)\n"
"vovan189: shows [6d As] (a straight, Deuce to Six)\n"
"DiMers80: shows [Kc Th] (a straight, Ace to Five)\n"
"vovan189 collected 1555 from pot\n"
"vovan189 wins the $0.44 bounty for eliminating SITBACKNOW\n"
"vovan189 wins the $0.44 bounty for eliminating DiMers80\n"
"SITBACKNOW finished the tournament in 35th place\n"
"DiMers80 finished the tournament in 35th place\n"
"*** SUMMARY ***\n"
"Total pot 1555 | Rake 0 \n"
"Board [5c 2c 3s Ah 4s]\n"
"Seat 1: vitalijus (button) folded before Flop (didn't bet)\n"
"Seat 2: papoca555 (small blind) folded before Flop\n"
"Seat 3: SITBACKNOW (big blind) showed [Ks Tc] and lost with a straight, Ace to Five\n"
"Seat 4: hackerpex folded before Flop (didn't bet)\n"
"Seat 5: vovan189 showed [6d As] and won (1555) with a straight, Deuce to Six\n"
"Seat 6: DiMers80 showed [Kc Th] and lost with a straight, Ace to Five\n"
"PokerStars Hand #152844655854: Tournament #1556870024, $0.44+$0.44+$0.12 USD Hold'em No Limit - Level I (25/50) - 2016/05/04 13:15:28 BRT [2016/05/04 12:15:28 ET]\n"
"Table '1556870024 3' 6-max Seat #2 is the button\n"
"Seat 1: vitalijus (490 in chips) \n"
"Seat 2: papoca555 (465 in chips) \n"
"Seat 4: hackerpex (490 in chips) \n"
"Seat 5: vovan189 (1555 in chips) \n"
"vitalijus: posts the ante 10\n"
"papoca555: posts the ante 10\n"
"hackerpex: posts the ante 10\n"
"vovan189: posts the ante 10\n"
"hackerpex: posts small blind 25\n"
"vovan189: posts big blind 50\n"
"*** HOLE CARDS ***\n"
"Dealt to hackerpex [Jd Ad]")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html