aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--re.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/re.c b/re.c
index 352e5f0c73..f3be9a1fce 100644
--- a/re.c
+++ b/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