Skip to content

Instantly share code, notes, and snippets.

@jwcooper
Created March 25, 2024 21:49
Show Gist options
  • Save jwcooper/3793b4b4274984720e83c9c628fdaf16 to your computer and use it in GitHub Desktop.
Save jwcooper/3793b4b4274984720e83c9c628fdaf16 to your computer and use it in GitHub Desktop.
import re
for test_string in ['555-1212', 'ILL-EGAL']:
if re.match(r'^\d{3}-\d{4}$', test_string):
print (test_string, 'is a valid US local phone number')
else:
print (test_string, 'rejected')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment