note 34962 deleted from function.ereg by didou

From: Date: Wed, 13 Aug 2003 13:42:12 +0000
Subject: note 34962 deleted from function.ereg by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54078@lists.php.net to get a copy of this message
Note Submitter: dan@reachmultimedia.com ---- My first time with RegExps today... learning a lot fo PHP very quickly at the moment so it kind of caused me some headaches as I'm sure you've all had at some point;) I was trying to work out an email validation expression of my own so that I could learn how to do this and understand the code. I found that many of the examples had some problems such as not including the new(ish) domains such as .museum, .info, etc or forgetting that some people may have an email address at a sub-domain such as: dan@sub.domain.com or a sub-domain at a foreign tld: dan@sub.domain.co.uk or dan@sub.domain.com.au. Took a while but I think I've cracked it! eregi("^([a-z0-9\._-])+@([a-z0-9\._-])+\.([a-z]{2,6}) (\.[a-z]{2,3})?$", $address) where $address is the variable holding the email address. Hope this helps somebody!

« previous php.notes (#54078) next »