note 52336 added to function.eregi

From: Date: Thu, 28 Apr 2005 08:45:31 +0000
Subject: note 52336 added to function.eregi
Groups: php.notes 
Request: Send a blank email to php-notes+get-88674@lists.php.net to get a copy of this message
<?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>'; } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.eregi.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52336 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52336&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52336&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52336&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52336&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52336&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52336&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88674) next »