note 101609 added to function.preg-match

From: Date: Thu, 30 Dec 2010 05:24:28 +0000
Subject: note 101609 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-175322@lists.php.net to get a copy of this message
That's not a real world email address sanitizer, THIS is a real world email address sanitizer. Someone took a week to figure it out a few years back ;) <?php function san_email($email){ $email = preg_replace('/[^a-z0-9-_\+\.@]/i', null, $email); if(preg_match("/^([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-]*[a-z0-9]+)*) \.[a-z]{2,6}$/i", $email)){ return $email; } } ---- Server IP: 216.235.13.26 Probable Submitter: 174.4.35.108 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/101609 Del: integrated -- https://master.php.net/note/delete/101609/integrated Del: useless -- https://master.php.net/note/delete/101609/useless Del: bad code -- https://master.php.net/note/delete/101609/bad+code Del: spam -- https://master.php.net/note/delete/101609/spam Del: non-english -- https://master.php.net/note/delete/101609/non-english Del: in docs -- https://master.php.net/note/delete/101609/in+docs Del: other reasons-- https://master.php.net/note/delete/101609 Reject -- https://master.php.net/note/reject/101609 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175322) next »