Skip to content

Instantly share code, notes, and snippets.

Created January 17, 2013 12:49
Show Gist options
  • Save anonymous/4555724 to your computer and use it in GitHub Desktop.
Save anonymous/4555724 to your computer and use it in GitHub Desktop.
better solution from stackoverflow...
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. "
string.to_enum(:scan,/(jack|jill)/i).map do |m,|
p [$`.size,m]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment