From: ekitten-listed at comcast dot net
Operating system: Linux
PHP version: 4.3.6
PHP Bug Type: *Regular Expressions
Bug description: preg_split doesn't behave as expected for empty tokens
Description:
------------
If I call preg_split with a string such as ",,foo,,bar,," I expect to get
five empty strings back in the returned array, but I only get back two -
the first and the last.
Reproduce code:
---------------
$tokens = preg_split("/[,]+/", ",,foo,,bar,,");
Expected result:
----------------
I expect $tokens to contain the following array:
array(12) {
[0]=> string(0) ""
[1]=> string(0) ""
[2]=> string(3) "foo"
[3]=> string(0) ""
[4]=> string(3) "bar"
[5]=> string(0) ""
[6]=> string(0) ""
}
Actual result:
--------------
array(12) {
[0]=> string(0) ""
[1]=> string(3) "foo"
[2]=> string(3) "bar"
[3]=> string(0) ""
}
--
Edit bug report at http://bugs.php.net/?id=28755&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28755&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28755&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28755&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28755&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28755&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28755&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28755&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28755&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28755&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28755&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28755&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28755&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28755&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28755&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28755&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28755&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28755&r=float