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:
- myre = compile(pattern)
- if myre.match(phn):
- return True
- return False
Add Comment
Please, Sign In to add comment