Created
September 27, 2013 13:49
-
-
Save TrevMcKendrick/6728872 to your computer and use it in GitHub Desktop.
todo parse phone #'s
This file contains 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
def normalize_phone_number(str) | |
parsed_str = str.gsub(/[^0-9]/, "") | |
return str if parsed_str.length != 10 | |
parsed_str.insert(0, "(") | |
parsed_str.insert(4, ") ") | |
parsed_str.insert(9, "-") | |
return parsed_str | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment