Skip to content

Instantly share code, notes, and snippets.

@nilium
Created January 16, 2015 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilium/cd748ab91a0be5241b86 to your computer and use it in GitHub Desktop.
Save nilium/cd748ab91a0be5241b86 to your computer and use it in GitHub Desktop.
class String
def each_match(re)
return to_enum(:each_match, re) unless block_given?
n = 0
while n < self.length && m = re.match(self, n)
n = m.end(0)
yield m
end
self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment