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
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…
x
Reference in New Issue
Block a user