Figure 8.2b has two if statement conditions that contain what are called regular expressions. As indicated, these

Question:

Figure 8.2b has two if statement conditions that contain what are called regular expressions. As indicated, these are explained in the Java API Pattern class. This exercise is intended to help you get a better feeling for Java’s regular expressions and their usage. Use your Java API documentation on the Pattern class to answer these questions:

a) Write the regular expression for a character string starting with a ‘Z’ and containing any number of additional characters of any kind except for a space or a tab.

b) Write the regular expression for a string that represents a U.S. long- distance telephone number (three digits, a hyphen or space, three digits, a hyphen or space, and four digits).

c) What is the meaning of the regular expression, "[A–Z][a–z]*", which appears in Figure 8.2b?

Figure 8.2b

// This method verifies that first starts with an uppercase // letter and contains lowercase letters

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: