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
How to make regexp that matches @name - without any prefix before @
'@[\w]+' - matches @ plus suffix. How to separate email addressees from twitter handles?
import re string = '''Love, Kenneth, firstname.lastname@example.org, 555-555-5555, @kennethlove Chalkley, Andrew, email@example.com, 555-555-5556, @chalkers McFarland, Dave, firstname.lastname@example.org, 555-555-5557, @davemcfarland Kesten, Joy, email@example.com, 555-555-5558, @joykesten''' contacts = re.search(r'(?P<email>[\w]+?[+]?[\w]+@[\w]+.[\w]+).\s+(?P<phone>[\d]+-[\d]+-[\d]+)',string) twitters = re.search(r'(?P<twitter>[^\w]@[\w]+)',string, re.MULTILINE)