On Dec 26, 1:53 am, "Marco" <marv... / tin.it> 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]