Skip to content

Instantly share code, notes, and snippets.

@manleyhimself
Created September 27, 2013 14:22
Show Gist options
  • Save manleyhimself/6729352 to your computer and use it in GitHub Desktop.
Save manleyhimself/6729352 to your computer and use it in GitHub Desktop.
def normalize_phone_number(number)
clean_num = number.gsub(/[^0-9]/, "")
clean_num.length != 10 ? number : "(#{clean_num[0,3]}) #{clean_num[3,3]}-#{clean_num[6,4]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment