[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
Родитель b5f33ba76f
Коммит dee45ac231
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3582D74E1FEE4465
1 изменённых файлов: 11 добавлений и 0 удалений

11
re.c
Просмотреть файл

@ -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