As we mentioned *
is a regular expression special character. The
*
is used to indicate that zero or more of the previous
characters should be matched. Thus, the regular expression a*
will match any string that contains zero or more a
's.
Note that since a*
will match any string with zero or more
a
's, a*
will match all strings, since all strings
(including the empty string) contain at least zero a
's. So,
a*
is not a very useful regular expression.
A more useful regular expression might be baa*
. This regular
expression will match any string that has a b
, followed by one or
more a
's. Thus, the set of strings we are matching are those
that contain ba
, baa
, baaa
, etc. In other words,
we are looking to see if there is any "sheep speech" hidden in our
text.