Project

General

Profile

Actions

Bug #19746

closed

`String#index` with regexp and too large offset doesn't clear `$~`

Added by nobu (Nobuyoshi Nakada) 11 months ago. Updated 10 months ago.

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

Description

/./ =~ "a"
p "x".index(/0/, 4) #=> nil
p $~ #=> #<MatchData "a">

while rindex does.

/./ =~ "a"
p "x".rindex(/0/, 4) #=> nil
p $~ #=> nil

It seems since 1.9.

Actions

Also available in: Atom PDF

Like1
Like0Like0