subject

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'

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:00, QueenKy9576
Wich technology can a website use to allow you to listen to a concert live over the internet?
Answers: 3
image
Computers and Technology, 23.06.2019 00:40, QueenKy6050
Consider the following statements: struct nametype{string first; string last; }; struct coursetype{string name; int callnum; int credits; char grade; }; struct studenttype{nametype name; double gpa; coursetype course; }; studenttype student; studenttype classlist[100]; coursetype course; nametype name; mark the following statements as valid or invalid. if a statement is invalid, explain why. a.) student. course. callnum = "csc230"; b.) cin > > student. name; c.) classlist[0] = name; d.) classlist[1].gpa = 3.45; e.) name = classlist[15].name; f.) student. name = name; g.) cout < < classlist[10] < < endl; h.) for (int j = 0; j < 100; j++)classlist[j].name = name; i.) classlist. course. credits = 3; j.) course = studenttype. course;
Answers: 1
image
Computers and Technology, 23.06.2019 15:30, taapeters
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
image
Computers and Technology, 23.06.2019 22:20, kandi2565
What is a programming method that provides for interactive modules to a website?
Answers: 1
You know the right answer?
Fill in the function problem1. This function should return True if the input string is a valid phone...

Questions in other subjects:

Konu
Geography, 30.12.2020 14:00
Konu
Geography, 30.12.2020 14:00
Konu
Mathematics, 30.12.2020 14:00
Konu
Mathematics, 30.12.2020 14:00
Konu
Mathematics, 30.12.2020 14:00
Konu
Chemistry, 30.12.2020 14:00
Konu
Physics, 30.12.2020 14:00