ID: 29245 User updated by: joei at mail dot com Reported By: joei at mail dot com Status: Bogus Bug Type: *Regular Expressions Operating System: Linux PHP Version: 4.3.8 New Comment:
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 Previous Comments: ------------------------------------------------------------------------ [2004-07-18 18:52:20] [EMAIL PROTECTED] 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 When - is the 1st character in the range it does not need to be escaped, escaping it gives it special meaning. ------------------------------------------------------------------------ [2004-07-18 16:34:20] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29245&edit=1