This is a simple regular expression parser in Python. It takes two
parameters: a simple regular expression (which I’ll define later) and an input
string to match against the regex.
In this simple regex, this is the alphabet being recognized:
star (*): denotes any number of occurences (including zero) of the
previous literal;
period (.): denotes any literal character;
literals: any character not mentioned above;
It is also assumed that the regex is anchored. That is, it is
implicitly surrounded by beginning and end of line characters.
For simplicity, no input validation is being done, so it is assumed that all
regexes are valid (i.e. stars must be preceeded by a literal). The following
code is actually pretty short, so I’ll explain the idea behind the code as we
go through.