Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Kirome 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?