From:             mike at we11er dot co dot uk
Operating system: Windows
PHP version:      5.1.6
PHP Bug Type:     *Regular Expressions
Bug description:  Backreference to optional item breaks preg_match

Description:
------------
echo preg_match("/(.)?a\\1/", "a");

returns "0"

But since the back reference is to an optional item, if that item does not
exist, then the back reference should just be blank and thus the above
should match "a", i.e. nothing + 'a' + nothing

This is actually stopping quite an important feature from being developed
so I'd appreciate a speedy response. It might be something I'm doing
wrong, or maybe this isn't supported (but i think it should be).

Thanks in advance.

Reproduce code:
---------------
echo preg_match("/(.)?a\\1/", "a");

Expected result:
----------------
Should return TRUE.

Actual result:
--------------
returns FALSE.

-- 
Edit bug report at http://bugs.php.net/?id=38899&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38899&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38899&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38899&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38899&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38899&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38899&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38899&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38899&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38899&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38899&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38899&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38899&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38899&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38899&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38899&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38899&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38899&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38899&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38899&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38899&r=mysqlcfg

Reply via email to