diff --git a/reference/pcre/constants.xml b/reference/pcre/constants.xml index d3759e4a977b..269814f3a57c 100644 --- a/reference/pcre/constants.xml +++ b/reference/pcre/constants.xml @@ -94,8 +94,10 @@ This flag tells preg_match and preg_match_all to include unmatched subpatterns in - $matches as &null; values. Without this flag, unmatched - subpatterns are reported as empty strings, as if they were empty matches. + $matches as &null; values, including trailing + unmatched subpatterns. Without this flag, non-trailing unmatched + subpatterns are reported as empty strings, while trailing unmatched + subpatterns are omitted from the results entirely. Setting this flag allows to distinguish between these two cases. 7.2.0 diff --git a/reference/pcre/functions/preg-match-all.xml b/reference/pcre/functions/preg-match-all.xml index d5387b6952f1..54ba7af38125 100644 --- a/reference/pcre/functions/preg-match-all.xml +++ b/reference/pcre/functions/preg-match-all.xml @@ -242,10 +242,14 @@ Array PREG_UNMATCHED_AS_NULL - - If this flag is passed, unmatched subpatterns are reported as &null;; - otherwise they are reported as an empty string. - + + If this flag is passed, unmatched subpatterns are reported as &null; + and are always included in the results (including trailing ones). + Without this flag, unmatched subpatterns that are followed by a + matched subpattern are reported as an empty string, + while trailing unmatched subpatterns are omitted from the results + entirely. + @@ -301,6 +305,14 @@ Array + + 7.4.0 + + When the PREG_UNMATCHED_AS_NULL flag is used, + trailing unmatched capturing groups are now also included in the + result with the value &null;. Previously, they were omitted. + + 7.2.0 diff --git a/reference/pcre/functions/preg-match.xml b/reference/pcre/functions/preg-match.xml index 11587ac3144e..93f23f48d2a9 100644 --- a/reference/pcre/functions/preg-match.xml +++ b/reference/pcre/functions/preg-match.xml @@ -119,8 +119,12 @@ Array PREG_UNMATCHED_AS_NULL - If this flag is passed, unmatched subpatterns are reported as &null;; - otherwise they are reported as an empty string. + If this flag is passed, unmatched subpatterns are reported as &null; + and are always included in the results (including trailing ones). + Without this flag, unmatched subpatterns that are followed by a + matched subpattern are reported as an empty string, + while trailing unmatched subpatterns are omitted from the results + entirely. ]]> @@ -155,6 +165,22 @@ array(4) { [3]=> string(1) "c" } +array(2) { + [0]=> + string(1) "a" + [1]=> + string(1) "a" +} +array(4) { + [0]=> + string(1) "a" + [1]=> + string(1) "a" + [2]=> + NULL + [3]=> + NULL +} ]]> @@ -270,6 +296,14 @@ Array + + 7.4.0 + + When the PREG_UNMATCHED_AS_NULL flag is used, + trailing unmatched capturing groups are now also included in the + result with the value &null;. Previously, they were omitted. + + 7.2.0