Title: [Python] import re for test_string in ['555-1212', 'ILL-EGAL']: if re.match(r'^\d{3 Author: Asterisk Pastebin link: http://pastebin.com/abLLb05d First Edit: Tuesday 24th of January 2012 09:35:42 PM CDT Last Edit: Tuesday 24th of January 2012 09:35:42 PM CDT 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'