ID: 44463 User updated by: php at sameprecision dot org Reported By: php at sameprecision dot org Status: Bogus Bug Type: PCRE related Operating System: irrelevant PHP Version: 5.2.5 New Comment:
Why would you expect three matches for a,a ? Previous Comments: ------------------------------------------------------------------------ [2008-03-17 22:41:00] [EMAIL PROTECTED] This result is expected. Using pcretest: PCRE version 7.5-RC2 2007-12-27 re> /(a|)(,|$)/g data> a, 0: a, 1: a 2: , 0: 1: 2: data> a,a 0: a, 1: a 2: , 0: a 1: a 2: 0: 1: 2: Thanks. ------------------------------------------------------------------------ [2008-03-17 22:13:54] php at sameprecision dot org 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] => ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44463&edit=1