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.

JavaScript Regular Expressions in JavaScript Validating a Form Validating an Email

I think spaces are not allowed in email address!

I know we are not supposed to create a bullet-proof production-ready email validator regex in this basic course but obviously spaces are not allowed, so can't believe that the instructor came up with this [^@] for the first part of a valid email address. Quite strange. I'm not sure but maybe this particular segment needs to be reconsidered because according to his suggested regex something like these are valid! ')(@)(.com' , ' @ .com'

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,030 Points

Good point! And good for you for digging into the presentation to grasp a deeper understanding of code presented!

Looking at the RFC 5322 Official Standard for email regex (seen here), going into a full robust solution would be way passed the point of this introductory lesson: to expose the student to a basic application of regex. Email regex is a hard problem.

Keep up the good work!