note 52336 deleted from function.eregi by betz
| From: | betz@php.net | Date: | Thu, 06 Oct 2005 06:04:55 +0000 |
| Subject: | note 52336 deleted from function.eregi by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96475@lists.php.net to get a copy of this message | ||
Note Submitter: bobocop at bobocop dot cz
----
<?php
// Update for addresses a@a.a.aa
// 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[] = 'a@a.a.a.a.aa'; // matched
$email[] = 'a@a.99.00.a.aa'; // 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.
// here is the update
'(\.[a-z0-9-]+)*'. // May be followed by zero or more alphanumeric or hyphen characters.
'\.[a-z0-9-]{2,}'. // Must be followed by one sets consisting a period of two
// end of update
// or more alphanumeric or hyphen characters.
'$'; // Each set of characters (without first set) must start with a dot
foreach ($email as $example) {
if (eregi($regex, $example)) {
echo $example . ' matched<br>';
} else {
echo '<strong>'. $example . ' not matched</strong><br>';
}
}
?>