note 53615 added to function.preg-match

From: Date: Tue, 07 Jun 2005 13:05:49 +0000
Subject: note 53615 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-90057@lists.php.net to get a copy of this message
An imporvement of the regular expression from hackajar <matt> yahoo <trot> com for e-mail addresses is this: <?php if(preg_match( '/^[A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}$/i' , $data) ) return true; ?> This stops the domain name starting or ending with a hyphen (or a full stop), and limits the domain to a minimum 2 and a maximum 63 characters. I've also added a full stop in the last character class to allow for 63-character domain names with a country code like .org.uk. The 63 character limit is just for the bit before the TLD (i.e. only 'php', not '.net'). I think this is right, but I'm not totally sure. ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53615 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53615&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53615&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53615&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53615&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53615&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53615&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90057) next »