Project

General

Profile

Actions

Bug #18670

closed

MatchData#[start, length] pads nil values when negative start is given

Added by bjfish (Brandon Fish) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:108122]

Description

Example

irb(main):001:0> /(.)(.)(\d+)(\d)/.match("THX1138.")[-1, 10]
=> ["8", nil, nil, nil, nil, nil, nil, nil, nil, nil]

I would expect this to be consistent with String or Array for example:

irb(main):002:0> "hello"[-1, 10]
=> "o"
irb(main):003:0> [1,2,3][-1,10]
=> [3]

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Backport changed from 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.6: UNKNOWN, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED

It is since 2.4.0.

Actions #3

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset git|d8189ed23f02dd197453279aeee9be1785337d4f.


Return only captured range in MatchData [Bug #18670]

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • Backport changed from 2.6: UNKNOWN, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED to 2.6: UNKNOWN, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE

ruby_3_1 1cfc139f6d0cb80d6024b0c416976194929417cf merged revision(s) d8189ed23f02dd197453279aeee9be1785337d4f.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0