Skip to content

Instantly share code, notes, and snippets.

@sammachin
Last active December 16, 2015 00:29
Show Gist options
  • Save sammachin/5347517 to your computer and use it in GitHub Desktop.
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
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