please code in python regular expression   In some web forms, users must enter a phone number, and some of these aggravate users by accepting only a specific format. You have been hired to write a program that reads U.S. phone  numbers with the three-digit area and seven-digit local codes accepted as ten digits, or separated  into blocks using hyphens or spaces, and with the area code optionally enclosed in parentheses.  For example, all of these are valid: 555-123-1234, (555) 1234567, (555) 123 1234, and  5551234567. Read the phone numbers from user input and for each one echo the number in the  form “(999) 999 9999” or report an error for any that are invalid, or that don’t have exactly ten  digits.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 7PP
icon
Related questions
Question

please code in python regular expression

 

In some web forms, users must enter a phone number, and some of these aggravate users by
accepting only a specific format. You have been hired to write a program that reads U.S. phone 
numbers with the three-digit area and seven-digit local codes accepted as ten digits, or separated 
into blocks using hyphens or spaces, and with the area code optionally enclosed in parentheses. 
For example, all of these are valid: 555-123-1234, (555) 1234567, (555) 123 1234, and 
5551234567. Read the phone numbers from user input and for each one echo the number in the 
form “(999) 999 9999” or report an error for any that are invalid, or that don’t have exactly ten 
digits.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage