Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjohn larson
16,594 PointsDidn't get the right content in the groups. Last name was "Perotto, ", first name was "Pier Giorgio".
It looks to me like I got the correct result. What am I not seeing?
import re
string = 'Perotto, Pier Giorgio'
names = re.match(r"""
^(?P<last>[\w]*,\s)
(?P<first>[\w\s]*)$
""", string, re.X|re.M)
1 Answer
Jackson Lai
3,538 Pointsimport re
string = 'Perotto, Pier Giorgio'
names = re.match(r"""
^(?P<last>[\w]*,\s) #<-- in here '',\s" should be out of the bracket
(?P<first>[\w\s]*)$
""", string, re.X|re.M)
Jackson Lai
3,538 PointsI didn't give you the answer on my last comment, I just told you what you should do. Here is my answer.
import re
string = 'Perotto, Pier Giorgio'
names = re.match(r"""
^(?P<last>[\w]*),\s #<-- in here ",\s" should be out of ()
(?P<first>[\w\s]*)$
""", string, re.X|re.M)
john larson
16,594 Pointsjohn larson
16,594 PointsJackson, yours and mine look the same to me. Don't I have the \s outside [], for last name?