Issue #13135 has been updated by Tomoyuki Chikanaga.

Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE

----------------------------------------
Bug #13135: Regexp.last_match returns nil with s.rindex(//)
https://bugs.ruby-lang.org/issues/13135#change-63510

* Author: Shugo Maeda
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE
----------------------------------------
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?




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>