mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Return only captured range in MatchData
[Bug #18670]
This commit is contained in:
parent
ddd83e8462
commit
d8189ed23f
Notes:
git
2022-03-31 18:01:47 +09:00
Merged: https://github.com/ruby/ruby/pull/5740 Merged-By: nobu <nobu@ruby-lang.org>
2 changed files with 2 additions and 1 deletions
2
re.c
2
re.c
|
@ -2159,7 +2159,7 @@ match_aref(int argc, VALUE *argv, VALUE match)
|
|||
else if (beg > num_regs) {
|
||||
return Qnil;
|
||||
}
|
||||
else if (beg+len > num_regs) {
|
||||
if (beg+len > num_regs) {
|
||||
len = num_regs - beg;
|
||||
}
|
||||
return match_ary_subseq(match, beg, len, Qnil);
|
||||
|
|
|
@ -488,6 +488,7 @@ class TestRegexp < Test::Unit::TestCase
|
|||
assert_nil(m[5])
|
||||
assert_raise(IndexError) { m[:foo] }
|
||||
assert_raise(TypeError) { m[nil] }
|
||||
assert_equal(["baz", nil], m[-2, 3])
|
||||
end
|
||||
|
||||
def test_match_values_at
|
||||
|
|
Loading…
Add table
Reference in a new issue