Actions
Bug #18670
closedMatchData#[start, length] pads nil values when negative start is given
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.
Updated by nobu (Nobuyoshi Nakada) over 2 years ago
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) over 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
Like0
Like0Like0Like0Like0