note 95964 deleted from function.ereg by danbrown
| From: | danbrown@php.net | Date: | Sun, 31 Jan 2010 23:51:36 +0000 |
| Subject: | note 95964 deleted from function.ereg by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165534@lists.php.net to get a copy of this message | ||
Note Submitter: Tomasz W.
----
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.