From: Albert Schlef Date: 2009-01-25T09:40:19+09:00 Subject: Re: how to find the position of each match within a string Rados��aw Bu��at wrote: >>> You can examine the $~ global MatchData object, in a couple of ways: >>> >>> irb(main):003:0> "ello-hello".scan('e') do |match| >>> irb(main):004:1* p $~.pre_match.size >>> irb(main):005:1> end >>> 0 >>> 6 >> >> Interesting. Does that mean that String#scan() converts a String >> argument to RegExp? > > Yes it does, even if it search fixed-size string. I'm shocked. Why does it do this? (this conversion) And doesn't this mean that #scan is less efficient than it could have been? Isn't matching regexps slower than matching plain strings? -- Posted via http://www.ruby-forum.com/.