[ruby-core:80401] [Ruby trunk Bug#13135] Regexp.last_match returns nil with s.rindex(//)

From: nagachika00@...
Date: 2017-03-27 16:41:05 UTC
List: ruby-core #80401
Issue #13135 has been updated by nagachika (Tomoyuki Chikanaga).

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

ruby_2_3 r58176 merged revision(s) 57374.

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

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

In This Thread

Prev Next