From:             fn at fkn-systems dot de
Operating system: Linux
PHP version:      Irrelevant
PHP Bug Type:     Regexps related
Bug description:  preg_replace mistake

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 bug report at http://bugs.php.net/?id=30468&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30468&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30468&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30468&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30468&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30468&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30468&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30468&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30468&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30468&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30468&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30468&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30468&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30468&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30468&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30468&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30468&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30468&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30468&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30468&r=mysqlcfg

Reply via email to