Simple Email Regex
I have always been against using regular expressions for email validation. The spec is just too complex. So many forms validate me+you@gmail.com
as an error. Which is incorrect. So in the spirit of learning regex, I decided to try my hand. This pattern seems to match quite well for everything I have thrown at it. It is loose enough to allow flexibility, but strict enough to not let the blatant errors get by.
^((\S+)@(.+)(\.)(\S+))$
# Ruby only
Thoughts on it?
Written by Brandon Hansen
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#