Compsci 06, Spring 2012, Regex FUN, April 3
Name____________________ net-id _________ Name____________________ net-id _________
Name____________________ net-id _________ Name____________________ net-id _________
This downloadable tool
will help as you experiment with regular expressions.
- The expression
ate$ matches 540 words and the
expression ^s.*ate$ matches 30 words. What are the
differences and similarities (written description) between the
matches of these two expressions?
- The expression
^p.[o|a].e$ matches 14 words, what
features do
these words have in common?
- The regular expression
(....)\1 has one match, the
word
beriberi. A small change to the regex, (....).\1
generates
two matches: bandstands and hodgepodge. Explain why
beriberi doesn't match the second expression and why the two words
that match the second expression match it and not the first regex.
- The regex
(....).*\1 has 13 matches:
atherosclerosis
bandstands
beriberi
hodgepodge
kinnickinnic
knickerbocker
knickerbockers
lightweight
misunderstander
misunderstanders
nationalization
rationalization
rationalizations
Explain why atherosclerosis matches. Circle the five of these
that also match (.....).*\1 (there's one more dot).
- Find all the words that have all the vowels a,e,i,o,u and in that
order.
- Find the number of words that contain either "spis" or "spas" in
them. Ideally you'll do this using one regex. What is the regex?
- Find all seven letter palindromes using one regex.