#31895 [Opn->Bgs]: PREG_SPLIT_DELIM_CAPTURE returns delimiter twice

From: Date: Tue, 28 Jun 2005 20:55:49 +0000
Subject: #31895 [Opn->Bgs]: PREG_SPLIT_DELIM_CAPTURE returns delimiter twice
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81145@lists.php.net to get a copy of this message
ID: 31895 Updated by: nlopess@php.net Reported By: peter dot bauwens at b-rail dot be -Status: Open +Status: Bogus Bug Type: PCRE related Operating System: * PHP Version: 5CVS, 4CVS (2005-05-30) New Comment: This is totally bogus, because you are using capturing parentheses. If you change the supplied test cases to (?:) they will work as expected. Lets see test #2: $String = "test 12 test 123 test 123 test"; print_r(preg_split("/( 12(?:3){0,1} )/", $String, -1, PREG_SPLIT_DELIM_CAPTURE)); // note the ?: there outputs: ( [0] => test [1] => 12 [2] => test [3] => 123 [4] => test [5] => 123 [6] => test ) Previous Comments: ------------------------------------------------------------------------ [2005-06-28 22:13:57] peter dot bauwens at b-rail dot be I tried the Win32 snapshot, but the bug still exists. The recognicion is good, but I get to much return-values... ------------------------------------------------------------------------ [2005-06-27 01:22:30] tony2001@php.net Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip PCRE was upgraded to version 5.0. ------------------------------------------------------------------------ [2005-02-11 05:52:35] sniper@php.net Verified. ------------------------------------------------------------------------ [2005-02-10 15:16:09] peter dot bauwens at b-rail dot be I just found out something new (I hope it helps) If I try these 2 lines: $String = "test 12 test 123 test 123 test"; print_r(preg_split("/( 12(3){0,1} )/", $String, -1, PREG_SPLIT_DELIM_CAPTURE)); I get this as result: Array ( [0] => test [1] => 12 [2] => test [3] => 123 [4] => 3 [5] => test [6] => 123 [7] => 3 [8] => test ) ------------------------------------------------------------------------ [2005-02-10 15:10:01] peter dot bauwens at b-rail dot be I used a totally different directory for the PHP snapshot, copied the php.ini in the Windows-dir, I changed my path in the httpd.conf of my Apache2 server, and restarted the server. In phpinfo() I got the 'version 4.3.11-dev'... ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/31895 -- Edit this bug report at http://bugs.php.net/?id=31895&edit=1

« previous php.bugs (#81145) next »