Last active
December 16, 2015 00:29
-
-
Save sammachin/5347517 to your computer and use it in GitHub Desktop.
Python function to normalise a UK dialed number into an e.164 number
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 normalise(number): | |
if re.match("^00.*", number): | |
return number.lstrip("0") | |
elif re.match("^0[1-9].*", number): | |
return "44" + number.lstrip("0") | |
elif re.match("^\+44.*", number) | |
return number.lstrip("+") | |
else: | |
return number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment