1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* re.c (rb_reg_s_last_match): accept named capture's name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-12-09 13:35:38 +00:00
parent 2d101f0a87
commit e56e8c758d
3 changed files with 92 additions and 43 deletions

View file

@ -69,6 +69,12 @@ class TestRegexp < Test::Unit::TestCase
assert_equal('#<MatchData "&amp; y" foo:"amp" foo:"y">',
/&(?<foo>.*?); (?<foo>y)/.match("aaa &amp; yyy").inspect)
# MatchData#keys
/(?<id>[A-Za-z_]+)/ =~ "!abc"
assert_equal("abc", Regexp.last_match(:id))
/a/ =~ "b"
assert_equal(nil, Regexp.last_match)
assert_equal(nil, Regexp.last_match(1))
assert_equal(nil, Regexp.last_match(:foo))
end
end