From: Jeffrey Moss Date: 2006-01-04T21:25:17+09:00 Subject: Email address validation (was: silly regex question) I was just perfecting my email address validator, mine allows multiple email addresses in the email_address field: validates_format_of :email_address, :with => /^\s*(?:(?:[^,@\s]+)@(?:(?:[-a-z0-9]+\.)+[a-z]{2,}\s*(,\s*|\z)))+$/i, :allow_nil => true It doesn't do as careful of an inspection as yours, although I've seen some validations that are far more detailed. It'd be nice to have some people contribute their suggestions for the ultimate email address validation regular expression. I also have this handy method in my class: def email_addresses self.email_address.split(',').map{|a| a.lstrip.rstrip } end -Jeff On Wed, Jan 04, 2006 at 08:27:58AM +0900, Dan Kohn wrote: > Here's a rails example for validating email addresses. > > validates_format_of :login, :with => / > ^[-^!$#%&'*+\/=?`{|}~.\w]+ > @[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])* > (\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])*)+$/x, > :message => "must be a valid email address", > :on => :create > >