From: Florian Gross Date: 2007-07-02T01:56:22+09:00 Subject: [BUG] String#rindex with Regexp in 1.9 Hi, in 1.8: (ruby 1.8.4 (2005-12-24)) "blablabla".rindex("bla", 0) # => 0 "blablabla".rindex(/bla/, 0) # => 0 ["test1".rindex(/../, 2), Regexp.last_match.to_s] # => [2, "st"] ["test1".rindex(/.../, 2), Regexp.last_match.to_s] # => [2, "st1"] That is, for both strings and regular expressions a match occurs if the first matched character's index is <= start_offset. In 1.9: (ruby 1.9.0 (2007-06-30 patchlevel 0)) "blablabla".rindex("bla", 0) # => 0 "blablabla".rindex(/bla/, 0) # => nil ["test1".rindex(/../, 2), Regexp.last_match.to_s] # => [1, "es"] ["test1".rindex(/.../, 2), Regexp.last_match.to_s] # => [0, "tes"] For regular expressions a match now occurs if the last matched character's index is <= start_offset. For strings the behaviour is the same as in 1.8. The expectation is that str.rindex(substr, offset) should always be == str.rindex(Regexp.new(Regexp.escape(substr)), offset) Kind regards, Florian Gross