From: William James Date: 2007-12-26T20:09:59+09:00 Subject: Re: Index of the n-th occurrence On Dec 26, 1:53 am, "Marco" wrote: > Hi, some newbie questions... > > 1) How can I obtain all the indices of the occurrences of a pattern in a > string (and not only the index of the first one using "index")? And the > index of the n-th occurrence? Why do you want these indices? There may be an easier way to accomplish your goal. Ruby isn't APL. a = [] ==>[] "the thug's thews".scan(/.*?(th)/){ a << $~.begin(1) } ==>"the thug's thews" a ==>[0, 4, 11]