Skip to content

Instantly share code, notes, and snippets.

@serpent213
Created December 9, 2018 19:02
Show Gist options
  • Save serpent213/282f8910e346faf83b1919c64245c23d to your computer and use it in GitHub Desktop.
Save serpent213/282f8910e346faf83b1919c64245c23d to your computer and use it in GitHub Desktop.
phone number validation (regex)
#!/usr/bin/env python
import re
def isPhoneNumberRegEx(text):
return bool(re.match(r'^\d{3}-\d{3}-\d{3}$', text))
print('666 666 666 is a phone number: ')
print(isPhoneNumberRegEx('666-666-666'))
print('Moshi moshi is a phone number')
print(isPhoneNumberRegEx('Moshi moshi'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment