ID: 30468 Updated by: [EMAIL PROTECTED] Reported By: fn at fkn-systems dot de -Status: Closed +Status: Bogus Bug Type: Regexps related Operating System: Linux PHP Version: Irrelevant New Comment:
User error -> bogus Previous Comments: ------------------------------------------------------------------------ [2004-10-20 16:02:17] fn at fkn-systems dot de OBSOLETE: Was USER-ERROR: Sorry im very,very blind! :-( -- doku:preg_replace.html When working with a replacement pattern where a backreference is immediately followed by another number (i.e.: placing a literal number immediately after a matched pattern), you cannot use the familiar \\1 notation for your backreference. \\11, for example, would confuse preg_replace() since it does not know whether you want the \\1 backreference followed by a literal 1, or the \\11 backreference followed by nothing. In this case the solution is to use \${1}1. This creates an isolated $1 backreference, leaving the 1 as a literal. ------------------------------------------------------------------------ [2004-10-18 09:59:59] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip ------------------------------------------------------------------------ [2004-10-18 09:56:17] fn at fkn-systems dot de Description: ------------ In: PHP 4.3.4 (cli) (built: Sep 24 2004 13:01:46) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies (also in PHP4.1.2 and PHP-CGI) followed code (whitout newlines!) $dat='2004-10-17/15:45.15'; echo'_'.preg_replace('/([.^\x5b]*?)(\x5b\x5b.*?\x5d\x5d)(.*)/s','\\1'."$dat".'\\3','# foo 1bar [changed: [[tic:tac]]] foo 2bar #').'_'; gives me _# foo 1bar [changed: 004-10-17/15:45.15] foo 2bar #_ and not _# foo 1bar [changed: 2004-10-17/15:45.15] foo 2bar #_ Reproduce code: --------------- <?php $dat='2004-10-17/15:45.15'; // (whitout newlines!) echo'_'.preg_replace('/([.^\x5b]*?)(\x5b\x5b.*?\x5d\x5d)(.*)/s','\\1'."$dat".'\\3','# foo 1bar [changed: [[tic:tac]]] foo 2bar #').'_'; ?> Expected result: ---------------- _# foo 1bar [changed: 2004-10-17/15:45.15] foo 2bar #_ Actual result: -------------- _# foo 1bar [changed: 004-10-17/15:45.15] foo 2bar #_ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30468&edit=1