Bug #80865 [Opn]: preg_split ignores limit flag when pattern with \K has 0-width fullstring match
| From: | mickmackusa at mickmackusa dot com | Date: | Mon, 15 Mar 2021 01:49:29 +0000 |
| Subject: | Bug #80865 [Opn]: preg_split ignores limit flag when pattern with \K has 0-width fullstring match | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232709@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80865&edit=1
ID: 80865
User updated by: mickmackusa at mickmackusa dot com
Reported by: mickmackusa at mickmackusa dot com
Summary: preg_split ignores limit flag when pattern with \K
has 0-width fullstring match
Status: Open
Type: Bug
Package: PCRE related
PHP Version: 7.3.27
Block user comment: N
Private report: N
New Comment:
changed reporter identification
Previous Comments:
------------------------------------------------------------------------
[2021-03-15 01:15:54] mickmackusa at mickmackusa dot com
Description:
------------
preg_split() does not respect the limit parameter when \K is used to produce a zero-width fullstring
delimiter. https://3v4l.org/kQHQZ This bug seems to be present
since PHP7.3. Other preg_split() calls using zero-width-match-producing regular expressions do not
suffer the same bug.
https://3v4l.org/3KP1T
Test script:
---------------
var_export(preg_split('~.{3}\K~', 'abcdefghijklm', 3));
Expected result:
----------------
array (
0 => 'abc',
1 => 'def',
2 => 'ghijklm',
)
Actual result:
--------------
array (
0 => 'abc',
1 => 'def',
2 => 'ghi',
3 => 'jkl',
4 => 'm',
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80865&edit=1