From 1b5ce6132748f4766e167aebefd7028c0e93ea3c Mon Sep 17 00:00:00 2001 From: zzak Date: Sat, 6 Oct 2012 19:38:18 +0000 Subject: [PATCH] * string.c (rb_str_match): Clarify behavior for captured strings and local variable assignment Patch by Marcus Stollsteimer [ruby-dev:47668] [Bug #7062] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/string.c b/string.c index 71a06abacc..9281e4cfbb 100644 --- a/string.c +++ b/string.c @@ -2699,6 +2699,10 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str) * obj.=~, passing str as an argument. The default * =~ in Object returns nil. * + * Note: str =~ regexp is not the same as + * regexp =~ str. Strings captured from named capture groups + * are assigned to local variables only in the second case. + * * "cat o' 9 tails" =~ /\d/ #=> 7 * "cat o' 9 tails" =~ 9 #=> nil */