ID:               20528
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-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] [EMAIL PROTECTED]

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

Reply via email to