NetManiac

Witold Rugowski on web20 wave with Ruby on Rails

Email verification – regexp

Posted on January 13, 2010 - Filed Under Ruby, Uncategorized, web

Many times before when I was supposed to collect emails from users I was googling to find some regexp to verify email syntax. At least I was aware that regexp challenging email address syntax is a bullshit ;) I was working few years as Unix sysadmin mostly on mail servers, so I had some idea how RFCs related to email are bloated ;) and contain so many exceptions ;)

Step back and think again

Step back and think again. Image CC by Vivianna_love

From some time I do use following regexp to verify email address:

 /.+@.+[.].+/

This should check if:

Why such simple rules? I have found comment on StackOverflow, that man should step back and think why is checking email address?

I want just to help users and stop them making simple mistakes in theirs emails. Like not providing @ at all. Or eating .com in gmail.com address. And that’s it – email will be probably shortly after that verified with only reliable method via sending email to this address.

And if You insist to verify emails with more strict regular expression, please do remember that plus sign is perfectly valid character before @. Many regexps found via google are forgetting that…

Popularity: 16% [?]

Hits for this post: 3262

Similar Posts

Comments

One Response to “Email verification – regexp”

  1. Sebastian Nowak on January 14th, 2010 8:47

    This make sense for me.

Leave a Reply