You are on page 1of 1

LISTA DE EJERCICIOS

Programar en Java los enunciados siguientes:


1. Write a regular expression for each of the following sets of binary strings. Use only
the basic operations.
(a) all binary strings except empty string
(b) begins with 1, ends with 1
(c) ends with 00
(d) contains at least three 1s
2. Write a regular expression for each of the following sets of binary strings. Use only
the basic operations.
(a) contains at least three consecutive 1s
(b) contains the substring 110
(c) contains the substring 1101100
(d) doesn't contain the substring 110
3. Write a regular expression for each of the following sets of binary strings. Use only
the basic operations.
(a) has at least 3 characters, and the third character is 0
(b) number of 0s is a multiple of 3
(c) starts and ends with the same character
(d) odd length
(e) starts with 0 and has odd length, or starts with 1 and has even length
(f) length is at least 1 and at most 3
4. Write a Java regular expression to match phone numbers, with or without area
codes. The area codes should be of the form (609) 555-1234 or 555-1234.
5. Find all English words that end with nym.
6. Write a Java regular expression to match all strings that contain exactly five vowels
and the vowels are in alphabetical order.
7. Given a string s that represents the name of an IP address in dotted quad notation,
break it up into its constituent pieces, e.g., 255.125.33.222. Make sure that the four
fields are numeric.
8. Write a Java regular expression to describe all dates of the form Month DD, YYYY
where Month consists of any string of upper or lower case letters, the date is 1 or 2
digits, and the year is exactly 4 digits. The comma and spaces are required.
9. Write a Java regular expression to match license plates that start with 4 digits and
end with two uppercase letters.

You might also like