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 trialTaylor Schimek
19,318 PointsTrouble with Regex code challenge
Challenge accepts solution to task 1.
Then, when checking task 2 it returns: Oops! It looks like take 1 is no longer passing.
I didn't change anything from the task 1 section.
Any ideas?
import re
string = '''
Love, Kenneth, kenneth+challenge@teamtreehouse.com, 555-555-5555, @kennethlove
Chalkley, Andrew, andrew@teamtreehouse.co.uk, 555-555-5556, @chalkers
McFarland, Dave, dave.mcfarland@teamtreehouse.com, 555-555-5557, @davemcfarland
Kesten, Joy, joy@teamtreehouse.com, 555-555-5558, @joykesten
'''
# task 1
contacts = re.search(r'''
(?P<email>[-\w\d.+]+@[-\w\d.]+) #email
,\s+
(?P<phone>\d{3}-\d{3}-\d{4}) #phone
''', string, re.X)
# task 2
twitters = re.search(r'(\s@[\w\d]+)$', string, re.X|re.M)
2 Answers
Dustin James
11,364 PointsYou are so close. You do not need to check for the space before the twitter handle.
twitters = re.search(r'(@[\w\d]+)$', string, re.M)
Taylor Schimek
19,318 PointsStill got the same Oops! Looks like task1 is no longer passing.
Taylor Schimek
19,318 PointsTaylor Schimek
19,318 PointsStill getting that task 1 is no longer passing. Can't see how i'm affecting the Task 1 code?? Thanks, though, for catching that space before the Twitter handle.
Dustin James
11,364 PointsDustin James
11,364 PointsTry removing
re.X
as you are not needingVERBOSE
Taylor Quinn
20,003 PointsTaylor Quinn
20,003 PointsWhy do we only mark the end of the string and not the beginning?