Bug #80865 [Opn->Spm]: preg_split ignores limit flag when pattern with \K has 0-width fullstring match

From: Date: Mon, 15 Mar 2021 01:59:35 +0000
Subject: Bug #80865 [Opn->Spm]: 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-232710@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 Updated by: danack@php.net Reported by: mickmackusa at mickmackusa dot com Summary: preg_split ignores limit flag when pattern with \K has 0-width fullstring match -Status: Open +Status: Spam Type: Bug Package: PCRE related PHP Version: 7.3.27 Block user comment: N Private report: N New Comment: user wanted to change email, and I don't have permission to edit, so they re-opening. Previous Comments: ------------------------------------------------------------------------ [2021-03-15 01:49:29] mickmackusa at mickmackusa dot com changed reporter identification ------------------------------------------------------------------------ [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

« previous php.bugs (#232710) next »