From: Bertram Scharpf Date: 2009-08-28T18:13:56+09:00 Subject: Re: I need a string#all_indices method--is there such a thing? Hi, Am Freitag, 28. Aug 2009, 17:40:05 +0900 schrieb timr: > Scan gives you the matches, not the indices (which is what I need). > > >> "this is a test for scan".scan(/t/) > => ["t", "t", "t"] There's a trick to do it with String#scan: a = [] "this is a test for scan".scan( /t/) { a.push $`.length } a This does not work when the matches overlap. "banana".scan /ana/ #=> ["ana"] Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de