Page 1 of 1

validating an email with a ' in it

Posted: Mon Mar 05, 2007 9:28 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:31 am
by Kieran Huggins
adding a ' to your character class should do the trick

Posted: Mon Mar 05, 2007 9:49 am
by feyd
Duplicate thread. Locked.