From: botp Date: 2009-05-29T00:48:05+09:00 Subject: Re: multiple matches On Thu, May 28, 2009 at 9:34 PM, Li Chen wrote: > How to find out pattern'cat'  in this string='ccccatgggctacatgggtcat' > ? There are three 'cat' within the string and I want to  return  the position of each match. there is String#index. there is no indexes, but you can build one if you like eg, > s => "ccccatgggctacatgggtcat" > class String > def indexes str, n=0 > n=index( str, n) > if n > [n] + indexes( str, n+=1) > else > [] > end > end > end => nil > s.indexes "cat" => [3, 12, 19] the faster way is to loop, but i just want to test my recursion skill ;) best regards -botp