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!
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 trial
Aidan Taylor-Lynch7,630 Points
How do I match two different groups, such that the first \w+ group is different to the second \+ group
How do I match two different groups, such that the first \w+ group is different to the second + group
string = 'Perotto, Pier Georgio'
names = re.match(r'(?P<last_name>[\w]+)(?P<first_name>[\w]+ [\w]+)', string, re.I)
import re string = 'Perotto, Pier Giorgio'
Peter Lawless24,404 Points
You are SO close, Aidan. The <last_name> and <first_name> fields are separated by a comma and a space, but the expression that you provided expects the fields to be right up against each other. These tiny little details are often what make or break the match. Let me know if this fixes your problem.