note 95964 added to function.ereg

From: Date: Sun, 31 Jan 2010 22:48:20 +0000
Subject: note 95964 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-165531@lists.php.net to get a copy of this message
Here's an extended pattern for email veritication: <?php if (!eregi("^([a-z]{1})([a-z0-9]*)([\.|_|-]?)([a-z0-9]*)([@]{1}) ([a-z0-9]*)([\.|_|-]?)([a-z0-9]*)([\.]{1})([a-z]{2,5})$",$email)) print "Invalid email!"; else print "all is ok!<br />$email"; ?> It's true for: aa@aa.aa aa.aa@aa.aa aa_aa@aa.aa aa-aa@aa.aa aa@aa.aa.aa aa@aa-aa.aa aa@aa_aa.aa ...... etc. Anything else will return error message. Also here's something to keep in mind. Don't use dash between special characters, even if it's separated with '|'. Like in the example below: ([\.|-|_]?) - incorrect ([\.|_|-]?) - correct It seems ereg tries to interpret dash and values on its sides as range regardles of '|' being used. Either type dash to remove its special function or put it at the end. ---- Server IP: 69.147.83.197 Probable Submitter: 89.74.162.232 ---- Manual Page -- http://www.php.net/manual/en/function.ereg.php Edit -- https://master.php.net/note/edit/95964 Del: integrated -- https://master.php.net/note/delete/95964/integrated Del: useless -- https://master.php.net/note/delete/95964/useless Del: bad code -- https://master.php.net/note/delete/95964/bad+code Del: spam -- https://master.php.net/note/delete/95964/spam Del: non-english -- https://master.php.net/note/delete/95964/non-english Del: in docs -- https://master.php.net/note/delete/95964/in+docs Del: other reasons-- https://master.php.net/note/delete/95964 Reject -- https://master.php.net/note/reject/95964 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#165531) next »