From: Andrea Dallera Date: 2010-04-14T02:21:05+09:00 Subject: Re: How to find multiple matches in a string string = "abcde abcde abcde" sum = 0 result = [] blocks = string.split(/b/) blocks.pop blocks.each do |block| sum += block.length result << sum sum += 1 end p result # [1,7,13] Don't tell anyone I've written this crap :-) -- Andrea Dallera http://github.com/bolthar/freightrain http://usingimho.wordpress.com On Wed, 2010-04-14 at 02:01 +0900, Alex DeCaria wrote: > Andrea Dallera wrote: > > Hei, > > > > s = 'abcde_abcde_abcde' > > m = s.scan(/b/) > > p m # ['b','b','b'] > > > > HTH > > > > -- > > Andrea Dallera > > http://github.com/bolthar/freightrain > > http://usingimho.wordpress.com > > Thanks Andrea. But is there a way to also find the locations (indexes) > of the 'b' characters? > > --Alex