Page 1 of 1

validating an email with a ' in it

Posted: Mon Mar 05, 2007 9:16 am
by hame22
Hi

My current email validation script will not allow any emails with a ' in to be validate e.g.(a.o'reilly@domain.com).

I'm currently using:

Code: Select all

(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $email))

any ideas?

Thanks in advance

Posted: Mon Mar 05, 2007 9:25 am
by Chris Corbyn
Wrong forum, PHPDN Suggestions is for forum suggestions ;)

There are heaps of email regex out there. In fact, if you search this forum you'll find the definitive RFC compliant one.

Posted: Mon Mar 05, 2007 9:27 am
by hame22
sorry complete mistake i put my question here, i am sorry!

Posted: Mon Mar 05, 2007 9:30 am
by Kieran Huggins
add a ' to your character class

Posted: Mon Mar 05, 2007 9:45 am
by hame22
sorry very stupid question I know but whre abouts is the character class in the expression?
thanks again

Posted: Mon Mar 05, 2007 9:47 am
by feyd
Just use the RFC compliant regex that has been posted many many many times.

"validateEmailFormat"