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:
parent
2d101f0a87
commit
e56e8c758d
3 changed files with 92 additions and 43 deletions
|
@ -69,6 +69,12 @@ class TestRegexp < Test::Unit::TestCase
|
|||
assert_equal('#<MatchData "& y" foo:"amp" foo:"y">',
|
||||
/&(?<foo>.*?); (?<foo>y)/.match("aaa & 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue