#41077 [Opn->WFx]: Order may matter between brackets when using ereg()
| From: | tony2001@php.net | Date: | Fri, 18 May 2007 15:06:21 +0000 |
| Subject: | #41077 [Opn->WFx]: Order may matter between brackets when using ereg() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-112839@lists.php.net to get a copy of this message | ||
ID: 41077
Updated by: tony2001@php.net
Reported By: aeolianmeson at blitzeclipse dot com
-Status: Open
+Status: Wont fix
Bug Type: Regexps related
Operating System: 2000 Server
PHP Version: 5.1.2
New Comment:
Use PCRE functions.
I don't think anybody is going to maintain deprecated ereg() functions
in the nearest future.
Previous Comments:
------------------------------------------------------------------------
[2007-05-09 05:02:55] aeolianmeson at blitzeclipse dot com
I'm not exactly sure what you're referring to. I can use the exact same
pattern with preg successfully. Can you confirm, or provide me a
specific URL to clarify your explanation?
Consider the following, where preg returns true and ereg returns
false:
$strEmail = "abc@def-.com";
$strReg = "^[a-z0-9_\-\.]+@[a-z0-9_\-\.]+\.[a-z0-9_\-\.]+$";
var_dump(eregi($strReg, $strEmail));
$strReg = "/^[a-z0-9_\-\.]+@[a-z0-9_\-\.]+\.[a-z0-9_\-\.]+$/i";
var_dump(preg_match($strReg, $strEmail));
Thanks :) .
Dustin Oprea
------------------------------------------------------------------------
[2007-04-13 16:25:25] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Read about strings with double quotes. The \\ won\'t be seen by the
regexp engine.
------------------------------------------------------------------------
[2007-04-13 15:07:41] aeolianmeson at blitzeclipse dot com
Description:
------------
I needed to add a dash to a character class, so I appended it to the
present character class definition. It turns out that it wouldn't accept
unless I moved it to the middle.
Reproduce code:
---------------
// This works.
// $reg = "^[[:alnum:]_\.\-]+@[[:alnum:]_\.\-]+$";
// This does not work. The only difference
// is the order of the last two accepted
// characters in the first character class.
$reg = "^[a-z0-9_\-\.]+@[[:alnum:]_\.\-]+$";
var_dump(ereg($reg, 'ab-c@def.com'));
Expected result:
----------------
Does match.
Actual result:
--------------
Does not match.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41077&edit=1