Computers and Technology

Fill in the function problem1. This function should return True if the input string is a valid phone number and False if not. We define a valid phone number as follows: First, it contains an optional area code (3 digits) followed by 7 digits.
Second, there could be one of several possible formats for the phone number, where the Xs are digits:
(XXX) XXX-
XXX-XXX-
XXX-
ANY other format should not count as a valid phone number. Spaces before or after an otherwise number is considered invalid.
Remember that (, ), - and . are special characters for regular expressions. To search for those characters, you need to precede them with a backslash: \( \), \-, \..
Because we are looking for the entire string to be a phone number, you can either use ^ and $ to force a match to be at the beginning and end of a string, or you can use fullmatch instead of match or search.
Where problem1 is : (you can assume import re is already there)
def problem1(searchstring):
"""
Match phone numbers.
:param searchstring: string
:return: True or False
"""
pass'

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:30, ghopk5929
In the film "epic 2015," epic is the name for:
Answers: 3
image
Computers and Technology, 22.06.2019 10:30, dreyes439
You are almost finished updating a web site. as part of the update, you have converted all pages from html 4.0 to html5. the project is currently on schedule. however, your project manager has been asked by the marketing team manager to justify a day of time spent validating the site's html5 pages. the marketing team manager does not have technical knowledge of the internet or the web. which is the most appropriate explanation to provide to the marketing team manager?
Answers: 1
image
Computers and Technology, 22.06.2019 22:30, hmontalvo22
Who needs to approve a change before it is initiated? (select two.) -change board -client or end user -ceo -personnel manager -project manager
Answers: 1
image
Computers and Technology, 23.06.2019 11:30, magicalpenguin48
In cell h5 enter a formula that will calculate the percentage of attendees that went to the altamonte springs job fair in 2018.
Answers: 1
Do you know the correct answer?
Fill in the function problem1. This function should return True if the input string is a valid phone...

Questions in other subjects:

Konu
Mathematics, 11.02.2021 05:30
Konu
English, 11.02.2021 05:30
Konu
Chemistry, 11.02.2021 05:30
Konu
Mathematics, 11.02.2021 05:30
Konu
Mathematics, 11.02.2021 05:30