Project

General

Profile

Actions

Bug #13135

closed

Regexp.last_match returns nil with s.rindex(//)

Added by shugo (Shugo Maeda) about 7 years ago. Updated about 7 years ago.

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

Description

Regexp.last_match returns nil, if // is given to String#rindex:

lexington:ruby$ ruby -ve 'p "foo".rindex(//); p Regexp.last_match'
ruby 2.5.0dev (2017-01-17 trunk 57359) [x86_64-linux]
3
nil

while it returns a MatchData with String#index:

lexington:ruby$ ruby -ve 'p "foo".index(//); p Regexp.last_match' 
ruby 2.5.0dev (2017-01-17 trunk 57359) [x86_64-linux]
0
#<MatchData "">

Is this intended behavior?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0