Give a regular expression to describe phone numbers in all the various forms you can think of. Consider international numbers as well as the fact that different countries have different numbers of digits in area codes and in local phone numbers.
Added by Christian B.
Close
Step 1
A phone number can include an international country code, an area code, and the local number. The international country code is usually preceded by a plus sign (+). The area code and local number can vary in length depending on the country. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 87 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
USA Today reporter Paul Wiseman described the old rules for the three-digit telephone area codes by writing about "possible area codes with 1 or 0 in the second digit. (Excluded: codes ending in 00 or 11 , for toll-free calls, emergency services, and other special uses.)" Codes beginning with 0 or 1 should also be excluded. How many different area codes were possible under these old rules?
Probability
Counting
In the US, telephone numbers are 7-digit long. While real phone numbers have some restrictions, for example, they cannot start with 0 or 1, here we assume that all 7-digit sequences are possible, even 0000000. How many phone numbers: - start or end with two identical digits, for example 0012345, 1234511, or 2222222, - contain a substring of 5 consecutive digits. For example 0034567, 2567892, or 0123456.
Madhur L.
5) Telephone numbers in the United States begin with a 3 digit area code followed by 7 digits. Area codes and local telephone numbers cannot begin with O or I. How many telephone numbers are possible?
Donna D.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD