Actions
Bug #1312
closedString#rindex(Regexp, offset) doesn't seem to match greedily
Bug #1312:
String#rindex(Regexp, offset) doesn't seem to match greedily
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0]
Backport:
Description
=begin
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> $~
=> #<MatchData "g">
irb(main):005:0> $[0].offset(0)
=> "g"
irb(main):006: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
=end
Actions