|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2004-07-18 16:34 UTC] joei at mail dot com
 Description:
------------
I found ereg function in php 4.3.8 doesn't match some expression that I think it must be matched.
Look at example..
ereg('[\=\-]', 'a-b') = match
ereg('[\-\=]', 'a-b') = unmatch
I think 2 expressions is the same. But result is difference.
Reproduce code:
---------------
<?
echo "ereg('[\=\-]', 'a-b') = " ;
if (ereg('[\=\-]', 'a-b'))
	echo "match";
else 
	echo "unmatch";
echo "<br>";
echo "ereg('[\-\=]', 'a-b') = " ;
if (ereg('[\-\=]', 'a-b'))
	echo "match";
else 
	echo "unmatch";
echo "<br>";
?>
Expected result:
----------------
ereg('[\=\-]', 'a-b') = match
ereg('[\-\=]', 'a-b') = match
Actual result:
--------------
ereg('[\=\-]', 'a-b') = match
ereg('[\-\=]', 'a-b') = unmatch
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 06:00:01 2025 UTC | 
It is not only '\-' appear at first but everywhere except at the end, it doesn't match. eg, ereg('[\.\=\-]', 'a-b') = match ereg('[\.\-\=]', 'a-b') = unmatch