Email validation - apostrophe

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

Post Reply
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Email validation - apostrophe

Post by aceconcepts »

Hi,

I currently use a rather good email validation script, however, it does not validate apostrophes '.

I had a user register their email address and it was "o'connor@..."

My current validation prevented this user from using that email address.

How can I validate the use of apostrophes?

Thanks.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Email validation - apostrophe

Post by Kieran Huggins »

once the search index is back you can search for "email validation regex" for an RFC compliant version, then it's just a matter of running preg_match().

You can probably find the same thing on Google.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Email validation - apostrophe

Post by aceconcepts »

Thanks
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: Email validation - apostrophe

Post by Inkyskin »

Are apostrophes a valid email char? I have never seen it used before...
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Email validation - apostrophe

Post by Kieran Huggins »

strictly, yes; it's part of the spec. Though many email servers don't allow local account creation with one.

I have seen them used, and had to fix my app to allow them.
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: Email validation - apostrophe

Post by Inkyskin »

Ah ok, ta. Time to modify my regex's... bugger.
Post Reply