validating an email with a ' in it

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

validating an email with a ' in it

Post 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
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

adding a ' to your character class should do the trick
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Duplicate thread. Locked.
Locked