PHP 4.0 Bug #7628 Updated: Interval Flaw....

From: Date: Fri, 03 Nov 2000 19:35:25 +0000
Subject: PHP 4.0 Bug #7628 Updated: Interval Flaw....
Groups: php.dev 
Request: Send a blank email to php-dev+get-37015@lists.php.net to get a copy of this message
ID: 7628 Updated by: derick Reported By: mike@traverse.net Status: Closed Bug Type: *Regular Expressions Assigned To: Comments: User error, he needed ^ and $. Previous Comments: --------------------------------------------------------------------------- [2000-11-03 14:12:14] mike@traverse.net Actually, I tested it further, and found that a regex of: [0-9a-f.] Works like: [0-9a-f.]+ --------------------------------------------------------------------------- [2000-11-03 13:56:04] mike@traverse.net Following is a short script that I was writing for a friend. However, what I found in testing it, was that the following interval {4} was acting like {4,} Note specifically the test on $macadd4. Enjoy....:) Thanks, Mike --- <HTML> <BODY> <?php phpinfo(); $macadd1 = "12af.54eb.b23c"; $macadd2 = "12aF.54eb.b23c"; $macadd3 = "12af?54eb.b23c"; $macadd4 = "1111.54eb.b23c111111"; $macadd5 = "12af.4eba.b23c.4567"; $regexstr = "([0-9a-f]{4}.){2}([0-9a-f]{4})"; if (ereg($regexstr, $macadd1)) { echo ($macadd1 . " is a valid MAC Address!<P>n"); } else { echo ($macadd1 . " is <b>NOT</b> a valid MAC Address!<P>n"); } if (ereg($regexstr, $macadd2)) { echo ($macadd2 . " is a valid MAC Address!<P>n"); } else { echo ($macadd2 . " is <b>NOT</b> a valid MAC Address!<P>n"); } if (ereg($regexstr, $macadd3)) { echo ($macadd3 . " is a valid MAC Address!<P>n"); } else { echo ($macadd3 . " is <b>NOT</b> a valid MAC Address!<P>n"); } if (ereg($regexstr, $macadd4)) { echo ($macadd4 . " is a valid MAC Address!<P>n"); } else { echo ($macadd4 . " is <b>NOT</b> a valid MAC Address!<P>n"); } if (ereg($regexstr, $macadd5)) { echo ($macadd5 . " is a valid MAC Address!<P>n"); } else { echo ($macadd5 . " is <b>NOT</b> a valid MAC Address!<P>n"); } ?> </body> </html> --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=7628

« previous php.dev (#37015) next »