php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7628 Interval Flaw....
Submitted: 2000-11-03 13:56 UTC Modified: 2000-11-03 14:35 UTC
From: mike at traverse dot net Assigned:
Status: Closed Package: *Regular Expressions
PHP Version: 4.0.3pl1 OS: Redhat Linux 6.2-7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mike at traverse dot net
New email:
PHP Version: OS:

 

 [2000-11-03 13:56 UTC] mike at traverse dot 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>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-03 14:12 UTC] mike at traverse dot net
Actually, I tested it further, and found that a regex of:

[0-9a-f\.]

Works like:
[0-9a-f\.]+

 [2000-11-03 14:35 UTC] derick@php.net
User error, he needed ^ and $.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC