#38899 [Opn]: Backreference to optional item breaks preg_match

From: Date: Wed, 20 Sep 2006 13:34:32 +0000
Subject: #38899 [Opn]: Backreference to optional item breaks preg_match
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-102472@lists.php.net to get a copy of this message
ID: 38899 User updated by: mike at we11er dot co dot uk Reported By: mike at we11er dot co dot uk Status: Open Bug Type: *Regular Expressions Operating System: Windows PHP Version: 5.1.6 New Comment: I should also add that this happens with preg_split. Previous Comments: ------------------------------------------------------------------------ [2006-09-20 13:24:12] mike at we11er dot co dot uk 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 this bug report at http://bugs.php.net/?id=38899&edit=1

« previous php.bugs (#102472) next »