Created
August 13, 2013 13:39
-
-
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
This file contains hidden or 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
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