From: "Wolfgang Nádasi-Donner" Date: 2007-11-19T00:16:49+09:00 Subject: Re: Count substrings from a string Robert Dober wrote: > too bad scan does not have an overlap parameter It has the possibility :-) irb(main):001:0> "aaaaaa".scan(/(?=aa)/) do irb(main):002:1* puts "#{$~.pre_match}-#{$~[0]}-#{$~.post_match}" irb(main):003:1> end --aaaaaa a--aaaaa aa--aaaa aaa--aaa aaaa--aa => "aaaaaa" irb(main):004:0> "aaaaaa".scan(/(?=aa)/).length => 5 With the look ahead features severals things can be done. Wolfgang Nádasi-Donner -- Posted via http://www.ruby-forum.com/.