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.
sarvienn thevendran734 Points
Hey, I've been assigned to find certain emails from a string. Which part of my code is causing the error?
import re # Example: # >>> find_email("firstname.lastname@example.org, @support, email@example.com, firstname.lastname@example.org") # ['email@example.com', 'firstname.lastname@example.org', 'email@example.com'] def find_emails(string): cr7 = re.findall(r'\b[\w,\d,.,+]+\b@[\d,.]+,[\w,.]+',string) return cr7
Eric Cahanin14,868 Points
Inside the brackets, the . that normally matches everything matches only a literal '.' So after your @, you're requiring one or more digits or .'s. Try to simplify your regex so that it's easier to understand. For example, \w already matches digits, so you don't need to include \d inside the brackets. Something like https://regex101.com/ can help you get a feel for how things match.