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 trialKirome Thompson
5,350 PointsRegular expression pattern matching.
Not sure what I am doing wrong but I have this name groups regular expression that I cant see where I am going wrong can anyone help?
It will compile but it prints out 'none'
import re
string = 'Perotto, Pier Giorgio'
print(re.match(r'''
^(?P<fullname>[-\w ]+,\s[-\w ]+)$
''', string, re.X))
print(string)
Jonathan Kuhl
26,133 PointsI got it to work by removing the ^...$
that was surrounding the regex:
(?P<fullname>[-\w]+,\s[-\w]+)
Try using https://regexr.com/ when building regex.
1 Answer
Kirome Thompson
5,350 Points@kyle kitlinski
Hi yes it is part of the name groups of the python coding challenge it is supposed to take a variable names that is a re.match() against the string and should provide groups for the first and last names separate
Kirome Thompson
5,350 Pointswith both methods still not being accepted by treehouse compiler :(
kyle kitlinski
5,619 Pointskyle kitlinski
5,619 PointsWhat is the intended output? the name?