Name____________________ net-id _________ Name____________________ net-id _________ Name____________________ net-id _________ Name____________________ net-id _________This downloadable tool will help as you experiment with regular expressions.
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?
^p.[o|a].e$
matches 14 words, what
features do
these words have in common?
(....)\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.
(....).*\1
has 13 matches:
atherosclerosis bandstands beriberi hodgepodge kinnickinnic knickerbocker knickerbockers lightweight misunderstander misunderstanders nationalization rationalization rationalizationsExplain why atherosclerosis matches. Circle the five of these that also match
(.....).*\1
(there's one more dot).
if
w.startswith("<")
in the function
expand
below:
w
may require
expansion because it has tags in it, so the rule
is passed to expand
in case it's more than a simple word.
w
starts with a < symbol we
know a choice should be made to replace it, but the line
assigning to sent
could be replaced with:
rules
is a dictionary, accessing
the dictionary generates a random replacement for the key w
and that replacement also starts with a < symbol.
sent.strip()
is
returned rather than simply sent
?
sent
in
the for-loop.
sent
, not
just leading and trailing white-space.
colors
in the function
create_content
?