tags:

views:

1238

answers:

4

Does anyone know what the regular expression in Ruby is to verify an email address is in proper RFC 2822 email format?

What I want to do is:

string.match(RFC_2822_REGEX)

where "RFC_2822_REGEX" is the regular expression to verify if my string is in valid RFC 2882 form.

+1  A: 

Try this:

Lonzo
this REGEX allows for emails like "test@example/x.com" and therefor "test@example/////////////////////////////////x.com"
Midday
+1  A: 

Based on the answers to this similar question, you may want to reconsider using regex for this.

Gordon Wilson
A: 

http://theshed.hezmatt.org/email-address-validator

Does regex validation based on RFC2822 rules (it's a monster of a regex, too), it can also check that the domain is valid in DNS (has MX or A records), and do a test delivery to validate that the MX for the domain will accept a message for the address given. These last two checks are optional.

womble