#20528 [Opn->Ver]: preg_split drops characters (re-opens Bug #15413)

From: Date: Thu, 21 Nov 2002 23:28:35 +0000
Subject: #20528 [Opn->Ver]: preg_split drops characters (re-opens Bug #15413)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-25488@lists.php.net to get a copy of this message
ID: 20528 Updated by: iliaa@php.net Reported By: ianm@judcom.nsw.gov.au -Status: Open +Status: Verified Bug Type: PCRE related Operating System: win32 and linux -PHP Version: 4.2.3 +PHP Version: 4.3.0-dev/4.4.0-dev Previous Comments: ------------------------------------------------------------------------ [2002-11-20 19:15:59] ianm@judcom.nsw.gov.au 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 this bug report at http://bugs.php.net/?id=20528&edit=1

« previous php.bugs (#25488) next »