note 51282 added to function.eregi

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

« previous php.notes (#86988) next »