Project

General

Profile

Bug #11014

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

First, to see how `String#match` String#match works on my example: 

 ~~~ruby ~~~ 
 match = "foo".match(/^=*/) 
 match.pre_match    #=> "" 
 match[0]           #=> "" 
 match.post_match #=> "foo" 
 ~~~ 

 Now, if I used `String#partition` String#partition instead of `match`, match, I'd expect to get `["", "", "foo"]` (pre_match, match, post_match). However 

 ~~~ruby ~~~ 
 "foo".partition(/^=*/) #=> ["foo", "", ""] 
 ~~~ 

 `String#rpartition` String#rpartition returns the correct result (with the same regex).

Back