Regular expressions are simple but powerful ways of describing patterns for
strings of symbols. We will restrict our attention to describing binary strings
using only the special symbol * which means "zero or more occurrences".
So our simple regular expression will be a sequence of characters, all of which
are '0', '1' or '*'. Furthermore, each '*' will be preceded by a '0' or a '1'
and will apply to that single character.
For example, "01*00*" describes all strings that start with '0', then have
zero or more '1's, then have a '0', and then have zero or more '0's. The
shortest string that satisfies this description is "00".
Create a class Regulars that contains a method stringCt that is given a simple
regular expression regex and an int maxLen and that returns the number of distinct
strings that satisfy regex and contain between 0 and maxLen characters, inclusive.
|