From: David Ellis Date: 2009-03-24T15:16:12+09:00 Subject: [ruby-core:23009] [Bug #1312] String#rindex(Regexp, offset) doesn't seem to match greedily Bug #1312: String#rindex(Regexp, offset) doesn't seem to match greedily http://redmine.ruby-lang.org/issues/show/1312 Author: David Ellis Status: Open, Priority: Normal ruby -v: ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0] I may be wrong but I was expecting: "abcdefg ".rindex(/\w+/,10) to return 0. This is what actually happens: irb(main):003:0> "abcdefg ".rindex(/\w+/,10) => 6 irb(main):004:0> $~ => # irb(main):005:0> $~[0] => "g" irb(main):006:0> $~.offset(0) => [6, 7] The Regexp seems to match in a non-greedy way. The /\w+/ only matches the "g". I was expecting it to be greedy and match "abcdefg" and return 0 instead of 6. Please correct me if I'm wrong in my expectation. Thank you, David ---------------------------------------- http://redmine.ruby-lang.org