Duplicate reference subpattern `(?|` also allows repetition of named subpatterns
Open
Beginner friendly
Nobody has claimed this yet.
enhancement
Extension: pcre
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
This section only mentions duplicate numbered subpatterns inside the (?| … ) grouping, but it also supports named subpatterns, e.g.:
preg_match_all('/(?|(?P<x>f)oo|(?P<x>b)(ar|az))/', 'foo bar baz qux', $m);
var_dump($m);
yields:
array(4) {
[0]=>
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
[2]=>
string(3) "baz"
}
["x"]=>
array(3) {
[0]=>
string(1) "f"
[1]=>
string(1) "b"
[2]=>
string(1) "b"
}
[1]=>
array(3) {
[0]=>
string(1) "f"
[1]=>
string(1) "b"
[2]=>
string(1) "b"
}
[2]=>
array(3) {
[0]=>
string(0) ""
[1]=>
string(2) "ar"
[2]=>
string(2) "az"
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open reference/pcre/pattern.syntax.xml at the linked section around line 1502 and compare its description with the supplied PHP example. Update the section to mention named subpatterns in duplicate-reference groups, including the demonstrated behavior; done when the documentation accurately covers both numbered and named subpatterns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100