Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Read this article and then write regular expressions for the following items?. Note that your regular expressions must be as compact as possible? You are

image text in transcribed

image text in transcribed

Read this article and then write regular expressions for the following items?. Note that your regular expressions must be as compact as possible? You are only allowed to use the following regular expression constructs in your answers: ) (a) Quantifiers: +, ?, and {...} (b) Character classes: [...] (c) Grouping: (...) Note that the alternation (I) construct and predefined character classes (\d, \w etc.) are NOT allowed and CANNOT be used in these questions. 1. (2 points) A phone number in USA. A phone number in USA is a sequence of 10 digits (0-9). The digits are divided into 3 groups: a 3-digit area code, a 3-digit prefix, and a 4-digit suffix. The area code will never start with O or 1. To display a phone number, we can put a pair of parentheses3 around the area code; leave a space between the closing parenthesis and the prefix; and put a hyphen between the prefix and suffix. (There are many other commonly used formats, but we focus on this format only.) For example, the main phone number for FSU is (910) 672-1111". 2. (2 points) A Haskell variable. A Haskell variable is a sequence of one or more characters which can be either uppercase letter (A-Z), lowercase letters (a-z), digits (0-9), the underscore (-) character, or the apostrophe (1) characters. However, the first character must be either a lowercase letters or an underscore character. For example, both abc1, _xyz'" are valid Haskell variables. 4 3. (2 points) US state and zip code in postal addresses. When writing a postal address, the state is usually written as a 2-uppercase-letter abbreviation. There can be an optional space character between the state and the zip code. The zip code is either a simple zip code or a zip+4 code. The simple zip code is simply a group of 5 decimal digits (which can start with the digit 0). The zip+4 code is the simple zip code followed by a hyphen (-) character and then another group of 4 digits. For example, the state and zip code for FSU can be written as either NC28301, NC 28301, NC28301-4252", or NC 28301- 4252". 4. (2 points) An IP address. An IP address is a group of 4 integers separated by the dot character.. Each integer can be one to three digits. The standard defines each integer to be in the range of 0 to 255 (inclusive) but we are going to ignore this (that is, we are allowing each integer to be in the range of 0 to 999 inclusive). For example, the IP address of FSU's web site (www.uncfsu.edu) is 208.115.107.179

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

13.13. Derive Eq. (13.52).

Answered: 1 week ago