|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-03-17 22:41 UTC] felipe@php.net
[2008-03-17 22:49 UTC] php at sameprecision dot org
[2008-03-17 23:19 UTC] felipe@php.net
[2008-03-17 23:25 UTC] php at sameprecision dot org
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 14 17:00:01 2025 UTC |
Description: ------------ Performing a global match with empty alternative in subpattern followed by $ alternative in subpattern results in "extra" match. In the example below, I believe that preg_match_all should match the second 'a' in the first subpattern, match the end of subject assertion in the second subpattern and flag the global search as over. I've tried this with php5.2.5/pcre7.3 on linux. Reproduce code: --------------- $regex = '/(a|)(,|$)/'; echo preg_match_all($regex, 'a,', $m1, PREG_SET_ORDER)."\n"; print_r($m1); echo preg_match_all($regex, 'a,a' ,$m2, PREG_SET_ORDER)."\n"; print_r($m2); Expected result: ---------------- 2 Array ( [0] => Array ( [0] => a, [1] => a [2] => , ) [1] => Array ( [0] => [1] => [2] => ) ) 2 Array ( [0] => Array ( [0] => a, [1] => a [2] => , ) [1] => Array ( [0] => a [1] => a [2] => ) ) Actual result: -------------- 2 Array ( [0] => Array ( [0] => a, [1] => a [2] => , ) [1] => Array ( [0] => [1] => [2] => ) ) 3 Array ( [0] => Array ( [0] => a, [1] => a [2] => , ) [1] => Array ( [0] => a [1] => a [2] => ) [2] => Array ( [0] => [1] => [2] => ) )