In ruby you can use string#index as follows:
str = “some text”
But what if I want to get all the indices for a regex in the string?
Is there an string#all_indices method?
I wrote the following, which works, but there must be a more elegant
indices = 
index = 0
while index && index < self.length #index will be nil upon first
match failure, otherwise quit loop when index is equal to string
index = self.index(regex, index)
if index.is_a? Numeric #avoids getting a nil into the indices
indices << index
p “this is a test string for the ts in the worldt”.all_indices(/t/)
p “what is up with all the twitter hype”.all_indices(/w/)