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 trialAlexander Davison
65,469 PointsPlease help with this regex! (SOLVED)
"Bummer! Didn't get the right content in the groups." Why???
import re
string = 'Perotto, Pier Giorgio'
names = re.match(r"(\w+), (\w+)", string)
1 Answer
Kourosh Raeen
23,733 PointsYour pattern needs to catch the space in the first name.
Alexander Davison
65,469 PointsAlexander Davison
65,469 Points?
Kourosh Raeen
23,733 PointsKourosh Raeen
23,733 PointsIn the first name "Pier Giorgio", there is a space between "Pier" and "Giorgio" and your pattern is not catching that.
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsWhere exactly should I put the space? I am not catching "Giorgio" in the first place.
Kourosh Raeen
23,733 PointsKourosh Raeen
23,733 PointsIn the second group. Right now you have any number of letters in that group. Add to it so that it becomes any number of letters followed by a space followed by any number of letters.
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsOh thank you so much!