Skip to content

Instantly share code, notes, and snippets.

@pointcom
Last active January 24, 2018 10:13
Show Gist options
  • Save pointcom/0421e1d6b34674898942c8e854c831bc to your computer and use it in GitHub Desktop.
Save pointcom/0421e1d6b34674898942c8e854c831bc to your computer and use it in GitHub Desktop.
# http://ruby-doc.org/core-2.5.0/MatchData.html#method-i-named_captures
# Ruby >= 2.4
/(?<first_name>.+) (?<last_name>.+)/.match('Bobby Brown').named_captures
=> {"first_name"=>"Bobby", "last_name"=>"Brown"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment