Created
January 17, 2013 12:49
-
-
Save anonymous/4555724 to your computer and use it in GitHub Desktop.
better solution from stackoverflow...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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