note 51282 deleted from function.eregi by betz
| From: | betz@php.net | Date: | Thu, 06 Oct 2005 06:04:41 +0000 |
| Subject: | note 51282 deleted from function.eregi by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96474@lists.php.net to get a copy of this message | ||
Note Submitter: bobocop at bobocop dot cz
----
<?php
// Example results:
$email[] = 'foo@example.com'; // matched
$email[] = 'foo.bar@example.co.uk'; // matched
$email[] = 'foo_bar@example.com'; // matched
$email[] = '_foo_bar@example.com'; // matched
$email[] = 'foo@example.example'; // matched
$email[] = '_-._@-.--'; // matched
$email[] = '%#af.*&654_-._@-.--'; // matched
$email[] = 'any..thing@bla.bla'; // not matched
$email[] = '@.'; // not matched
$email[] = '@.com'; // not matched
$email[] = ' @ .com'; // not matched
$email[] = '.bar@example.com'; // not matched
$email[] = 'foo.@example.com'; // not matched
$email[] = 'foo@example.x.y'; // not matched
$regex = '^'.
'[-a-z0-9!#$%&\'*+/=?^_<{|}~]+'. // One or more underscore,
alphanumeric, or allowed characters.
'(\.[-a-zA-Z0-9!#$%&\'*+/=?^_<{|}~]+)*'. // Followed by zero or more sets
consisting of a period
// of one or more underscore, alphanumeric, or allowed
characters.
'@'. // Followed by an "at" character.
'[a-z0-9-]+'. // Followed by one or more alphanumeric or hyphen
characters.
'(\.[a-z0-9-]{2,})+'. // Followed by one or more sets consisting a
period of two
// or more alphanumeric or hyphen characters.
'$';
foreach ($email as $example) {
if (eregi($regex, $example)) {
echo $example . ' matched<br>';
} else {
echo $example . ' not matched<br>';
}
}
?>