[DOC] State MatchData#[] when multiple captures with the same name

This commit is contained in:
Nobuyoshi Nakada 2023-12-19 12:59:43 +09:00
parent b5f33ba76f
commit dee45ac231
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465

11
re.c
View File

@ -2151,6 +2151,17 @@ match_ary_aref(VALUE match, VALUE idx, VALUE result)
* m['foo'] # => "h"
* m[:bar] # => "ge"
*
* If multiple captures have the same name, returns the last matched
* substring.
*
* m = /(?<foo>.)(?<foo>.+)/.match("hoge")
* # => #<MatchData "hoge" foo:"h" foo:"oge">
* m[:foo] #=> "oge"
*
* m = /\W(?<foo>.+)|\w(?<foo>.+)|(?<foo>.+)/.match("hoge")
* #<MatchData "hoge" foo:nil foo:"oge" foo:nil>
* m[:foo] #=> "oge"
*
*/
static VALUE