#50463 [Bgs]: PREG_SPLIT eating character

From: Date: Sat, 12 Dec 2009 22:44:40 +0000
Subject: #50463 [Bgs]: PREG_SPLIT eating character
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-145678@lists.php.net to get a copy of this message
ID: 50463 User updated by: bellingan at email dot it Reported By: bellingan at email dot it Status: Bogus Bug Type: PCRE related Operating System: Suse Linux 11.2 PHP Version: 5.3.1 New Comment: $res=preg_split("/[a-z]../",$via,-1,PREG_SPLIT_DELIM_CAPTURE); Yes... Now is even more oddy... Giving array(4) { [0]=> string(4) "123G" [1]=> string(0) "" [2]=> string(1) "R" [3]=> string(1) "i" } Now I'm using the preg_match("/[a-z]..+/",$via,$res,PREG_OFFSET_CAPTURE); dump($m); giving a Array ( [0] => Array ( [0] => ata [1] => 4 ) ) Previous Comments: ------------------------------------------------------------------------ [2009-12-12 22:31:28] felipe@php.net The third param. is for the 'limit', not for flags. See the examples in the documentation. ------------------------------------------------------------------------ [2009-12-12 22:22:19] bellingan at email dot it Sorry it doesen't return at all the matched text... ------------------------------------------------------------------------ [2009-12-12 22:21:25] bellingan at email dot it Description: ------------ PREG_SPLIT whit the PREG_SPLIT_DELIM_CAPTURE flag, return the matched string dropping the first charcater. Like in http://bugs.php.net/bug.php?id=15413&edit=2 Reproduce code: --------------- $via="123Gatano_Rizzi"; $res=preg_split("/[a-z]../",$via,PREG_SPLIT_DELIM_CAPTURE); var_dump($res); Expected result: ---------------- array(2) { [0]=> string(4) "123G" [1]=> string(3) "ata" [2]=> string(8) "no_Rizzi" } Actual result: -------------- array(2) { [0]=> string(4) "123G" [1]=> string(8) "no_Rizzi" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50463&edit=1

« previous php.bugs (#145678) next »