Repository navigation
pcre: describe PREG_UNMATCHED_AS_NULL for trailing groups - #5272
Merged
lacatoire merged 1 commit intoAug 21, 2026
Merged
Conversation
lacatoire
force-pushed
the
fix/preg-unmatched-as-null-description
branch
from
June 23, 2026 14:11
80b0ee0 to
339dc08
Compare
lacatoire
force-pushed
the
fix/preg-unmatched-as-null-description
branch
from
August 21, 2026 08:49
339dc08 to
c8f311d
Compare
This was referenced Aug 22, 2026
KentarouTakeda
added a commit
to php/doc-ja
that referenced
this pull request
Oct 4, 2026
php/doc-en@aa5a948a11 (php/doc-en#5652)、php/doc-en@cdbe6f9826 (php/doc-en#5272)、 php/doc-en@f88f34ad2f (php/doc-en#5887) に追従します。 PREG_UNMATCHED_AS_NULL の説明に、末尾のマッチしなかったサブパターンの扱い (フラグなしでは結果に含まれず、フラグありでは &null; として含まれる) を追加し、 その例と出力、7.4.0 の変更履歴を加えました。 offset の注記の文言は php/doc-en@aa5a948a11 で変更され、php/doc-en@f88f34ad2f で 元に戻されているため、該当文はタグの変更のみです。 ## 対象ファイル (1件) - reference/pcre/functions/preg-match.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PREG_UNMATCHED_AS_NULLis described as:That is incomplete for
preg_match(): without the flag, an unmatched subpattern is only reported as an empty string when a later subpattern matched. Trailing unmatched subpatterns are dropped from$matchesentirely.Measured behaviour of the second call:
[0 => "a", 1 => "a"][0 => "a", 1 => "a", 2 => null, 3 => null]Hence the 7.4.0 changelog entry, which follows
UPGRADINGfor PHP 7.4:The
[null, -1]form is confirmed too: on 7.4.33 and 8.5.8,PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTUREyields2 => [null, -1], while 7.3.33 omits the entry.preg_match_all()is deliberately left untouched: it never had this behaviour. InPREG_PATTERN_ORDERthe array is indexed by group, so trailing groups are always present — as empty strings without the flag and as null with it, on 7.2.34 as on 8.5.8. Nothing changed there in 7.4.Fixes: #3483