Compsci 101, Fall 2014, Classwork Nov 18

Write regular expression patterns. Assume words will be tested on a string of words. Assume numbers will be tested on a string of numbers.

Put the answers to problems 1-3 in this form

Problem 1:

Write a regular expression that starts with a vowel a,e,i,o or u and ends in 'y'

Problem 2:

Write a regular expression for words that are of length 4

Problem 3:

Write a regular expression for words that don't start with 'f', and have 'as' as a substring.

Put the answers to problems 4-5 in this form

Problem 4:

Write a regular expression for an integer of length 4 that starts with 9.

Problem 5:

Write a regular expression for a decimal number.

Put the answers to problems 6-7 in this form

Problem 6:

A binary number has only 0's or 1's. Binary numbers are 0, 1, 10, 11, 100, 101, 110, 111, etc. Write a regular expression for binary numbers that are even numbers.

Problem 7:

Write a regular expression for binary numbers that are even numbers that have an even number of 1's. Examples of valid such number are 1010, 11110 and 1011010.