Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from re import compile
- VALID_PHONE_PATTERNS = [
- "^(\d{10})$",
- "^(\d{3})\-(\d{3})\-(\d{4})$",
- "^(\d{3})\.(\d{3})\.(\d{4})$",
- "^\((\d{3})\)\s?(\d{3})\-(\d{4})$",
- "^(\d{3})\-(\d{4})$"]
- def validate_phone_number(phn):
- for pattern in VALID_PHONE_PATTERNS:
- res = compile(pattern).findall(phn)
- if res:
- return "".join(res[0])
- return None
Add Comment
Please, Sign In to add comment