#20528 [NEW]: preg_split drops characters (re-opens Bug #15413)

From: Date: Thu, 21 Nov 2002 01:15:59 +0000
Subject: #20528 [NEW]: preg_split drops characters (re-opens Bug #15413)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-25368@lists.php.net to get a copy of this message
From: ianm@judcom.nsw.gov.au Operating system: win32 and linux PHP version: 4.2.3 PHP Bug Type: PCRE related Bug description: preg_split drops characters (re-opens Bug #15413) SUMMARY: preg_split incorrectly drops the first character of the last element of the array it creates, at least in some circumstances. The equivalent Perl code works correctly, and drops no characters. [the following stuff has been copied from my comment to Bug #15413, which I cannot re-open as I am not the owner] The following code splits and re-joins a string - it should produce the original string but doesn't. $foo = '(#11/19/2002#)'; // MS Access date constant $bar = preg_split('/\b/',$foo); $baz = join('',$bar); print $baz; result is: (#11/19/2002) The trailing hash character (#) is being dropped. I tried the equivalent program in Perl (see below) and it produces the *correct* result - so it is not a problem with the regex itself. (Perl source:) $foo = '(#11/19/2002#)'; # MS Access date constant @bar = split(/\b/,$foo); $baz = join('',@bar); print $baz; result is: (#11/19/2002#) I have experienced this problem on Win32 with PHP 4.2.3 and 4.1.2, and on Linux with PHP 4.04pl1 (RH7.1). The equivalent Perl code works correctly on both Win32 (Perl 5.6.1) and Linux (Perl 5.6.0). [NOTE: the person who originally reported this bug provided a much more complicated example. Apart from his and my examples, I don't know if any other circumstances can trigger this bug.] -- Edit bug report at http://bugs.php.net/?id=20528&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20528&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20528&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20528&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20528&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20528&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20528&r=support Expected behavior: http://bugs.php.net/fix.php?id=20528&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20528&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20528&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20528&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20528&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20528&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20528&r=isapi

« previous php.bugs (#25368) next »