ID: 15413 Comment by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Bogus Bug Type: PCRE related Operating System: win PHP Version: 4.0.6 New Comment:
I also have experienced dropped characters in preg_split, and it is not an error in my regex. I can demonstrate the problem with a very simple regex, and I get correct results from Perl using the equivalent code. 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 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). Previous Comments: ------------------------------------------------------------------------ [2002-02-07 06:41:34] [EMAIL PROTECTED] Very likely to be a error in your regex. Ask support questions on the appropriate mailinglist. ------------------------------------------------------------------------ [2002-02-06 19:27:52] [EMAIL PROTECTED] $html = {some html containing mulitple instances of "<!-- [some text] --> some text <-- end -->} $array = preg_split("'(?=<!--)(?!<!-- end -->)|(?<=\<!-- ende -->)'si", $html, -1, PREG_SPLIT_NO_EMPTY) preg_split should split the string in such a way, that the html-part and the commented part are each assigned to one array entry. preg_split does as expected, EXCEPT that the first character of the last array entry is disappears Server API Apache Win2000 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15413&edit=1