<filename>unit_03/07_Regular_Expressions/1-Regular_Expressions/11_players.py
#
#  Regular Expressions in Python
#  Python Techdegree
#
#  Created by <NAME> on 12/29/18.
#  Copyright (c) 2018 ddApps. All rights reserved.
# ------------------------------------------------
#  Challenge 9: Players Dictionary & Class
# ------------------------------------------------
#  Challenge Task 1 of 2 
#  Create a variable named players that is an 
#  re.search() or re.match() to capture three
#  groups: last_name, first_name, and score.
#  It should include re.MULTILINE.
import re

string = '''<NAME>: 20
<NAME>: 25
<NAME>: 10
<NAME>: 22
<NAME>, <NAME>: 18'''

players = re.search(r'''
    (?P<last_name>[\w ]*),
    \s
    (?P<first_name>[\w ]*):
    \s
    (?P<score>[\d]*)
''', string, re.M | re.X)

print(players)

# ------------------------------------------------
#  Challenge Task 2 of 2
#  Wow! OK, now, create a class named Player that 
#  has those same three attributes, last_name, 
#  first_name, and score. 
#  I should be able to set them through __init__.
class Player:
    def __init__(self, last_name, first_name, score):
        self.last_name = last_name
        self.first_name = first_name
        self.score = score

<filename>unit_03/07_Regular_Expressions/1-Regular_Expressions/11_players.py
#
#  Regular Expressions in Python
#  Python Techdegree
#
#  Created by <NAME> on 12/29/18.
#  Copyright (c) 2018 ddApps. All rights reserved.
# ------------------------------------------------
#  Challenge 9: Players Dictionary & Class
# ------------------------------------------------
#  Challenge Task 1 of 2 
#  Create a variable named players that is an 
#  re.search() or re.match() to capture three
#  groups: last_name, first_name, and score.
#  It should include re.MULTILINE.
import re

string = '''<NAME>: 20
<NAME>: 25
<NAME>: 10
<NAME>: 22
<NAME>, <NAME>: 18'''

players = re.search(r'''
    (?P<last_name>[\w ]*),
    \s
    (?P<first_name>[\w ]*):
    \s
    (?P<score>[\d]*)
''', string, re.M | re.X)

print(players)

# ------------------------------------------------
#  Challenge Task 2 of 2
#  Wow! OK, now, create a class named Player that 
#  has those same three attributes, last_name, 
#  first_name, and score. 
#  I should be able to set them through __init__.
class Player:
    def __init__(self, last_name, first_name, score):
        self.last_name = last_name
        self.first_name = first_name
        self.score = score

# #  Regular Expressions in Python #  Python Techdegree # #  Created by <NAME> on 12/29/18. #  Copyright (c) 2018 ddApps. All rights reserved. # ------------------------------------------------ #  Challenge 9: Players Dictionary & Class # ------------------------------------------------ #  Challenge Task 1 of 2 #  Create a variable named players that is an #  re.search() or re.match() to capture three #  groups: last_name, first_name, and score. #  It should include re.MULTILINE. <NAME>: 20 <NAME>: 25 <NAME>: 10 <NAME>: 22 <NAME>, <NAME>: 18 (?P<last_name>[\w ]*),     \s     (?P<first_name>[\w ]*):     \s     (?P<score>[\d]*) # ------------------------------------------------ #  Challenge Task 2 of 2 #  Wow! OK, now, create a class named Player that #  has those same three attributes, last_name, #  first_name, and score. #  I should be able to set them through __init__.