Skip to content

Instantly share code, notes, and snippets.

@dwaite
Created March 14, 2011 06:19
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 dwaite/868836 to your computer and use it in GitHub Desktop.
Save dwaite/868836 to your computer and use it in GitHub Desktop.
# Performs normal match and returns MatchData object from $~ or nil.
def match(str)
unless str
Regexp.last_match = nil
return nil
end
str = StringValue(str)
Regexp.last_match = search_region(str, 0, str.size, true)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment