Skip to content

Instantly share code, notes, and snippets.

@flarnie
Created August 13, 2013 13:39
Show Gist options
  • Save flarnie/6221219 to your computer and use it in GitHub Desktop.
Save flarnie/6221219 to your computer and use it in GitHub Desktop.
Convert Ruby Regex Matchdata into a hash quickly and easily. From the following stackoverflow post: http://stackoverflow.com/questions/11688726/convert-named-matches-in-matchdata-to-hash
matchdata = #Regex match expression here
matchdata_hash = Hash[ matchdata.names.zip( matchdata.captures ) ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment