note 88007 added to function.preg-match

From: Date: Tue, 06 Jan 2009 00:52:31 +0000
Subject: note 88007 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-148869@lists.php.net to get a copy of this message
I modified your email validation pattern to solve these issues: - the string MUST contain a TLD - TLD can be 2 letters long as well as 3 or more (ie: .ca, .us, .uk, .fr, etc.) - domain name (tld not included) must contain at least 2 characters - domain name can contain "-"if it's not the first nor the last character. <?php $pattern = '/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])' . '(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i'; echo preg_match ($pattern, "email-address-to-validate@host.tld"); ?> ---- Server IP: 66.207.199.35 Probable Submitter: 65.95.82.56 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/88007 Del: integrated -- https://master.php.net/note/delete/88007/integrated Del: useless -- https://master.php.net/note/delete/88007/useless Del: bad code -- https://master.php.net/note/delete/88007/bad+code Del: spam -- https://master.php.net/note/delete/88007/spam Del: non-english -- https://master.php.net/note/delete/88007/non-english Del: in docs -- https://master.php.net/note/delete/88007/in+docs Del: other reasons-- https://master.php.net/note/delete/88007 Reject -- https://master.php.net/note/reject/88007 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148869) next »