Bug #71199 [Com]: PREG_SPLIT_NO_EMPTY gives wrong result
| From: | inefedor at gmail dot com | Date: | Tue, 22 Dec 2015 18:50:03 +0000 |
| Subject: | Bug #71199 [Com]: PREG_SPLIT_NO_EMPTY gives wrong result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-198152@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71199&edit=1
ID: 71199
Comment by: inefedor at gmail dot com
Reported by: g dot statkute at gmail dot com
Summary: PREG_SPLIT_NO_EMPTY gives wrong result
Status: Open
Type: Bug
Package: PCRE related
Operating System: Windows 7
PHP Version: 5.5.30
Block user comment: N
Private report: N
New Comment:
The third parameter of preg_split is $limit. The right way to call it would be
preg_split("/[;,\.]+/", $keyw, -1, PREG_SPLIT_NO_EMPTY)
Previous Comments:
------------------------------------------------------------------------
[2015-12-22 18:27:25] g dot statkute at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.preg-split
---
Test script:
---------------
$keyw=" some, string,,, separaed by many ... different ; ; ;separators";
$searchArr = preg_split( "/[;,\.]+/", $keyw ,PREG_SPLIT_NO_EMPTY );
print_r($searchArr);
gives: Array ( [0] => some, string,,, separated by many ... different ; ; ;separators )
Expected result:
----------------
Array ( [0] => some [1] => string [2] => separated by many [3] => different [4] =>
separators )
Actual result:
--------------
Array ( [0] => some, string,,, separated by many ... different ; ; ;separators )
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71199&edit=1