string = \"Jack and Jill went up the hill to fetch a pail of water. Jack fell down and broke his crown. And Jill came tumbling after. \"
d = string.match(/(jack|jill
Here's a modification of Nakilon's answer if you want to put just the locations of "Jack" into an array
location_array = Array.new
string = "Jack and Jack went up the hill to fetch a pail of Jack..."
string.to_enum(:scan,/(jack)/i).map do |m,|
location_array.push [$`.size]
end