Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created December 14, 2011 06:21
Show Gist options
  • Save brandon-beacher/1475491 to your computer and use it in GitHub Desktop.
Save brandon-beacher/1475491 to your computer and use it in GitHub Desktop.
match_data = /(?<area_code>\d{3})-(?<prefix>\d{3})-(?<line_number>\d{4})/.match("678-248-2440")
if match_data
PhoneNumber.new(
area_code: match_data[:area_code],
prefix: match_data[:prefix],
line_number: match_data[:line_number])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment