Thus, complex expressions can easily be constructed from simpler ones like the primitives described here. For details of the theory and implementation of regular expressions, consult almost any textbook about compiler construction. A brief explanation of the format of regular expressions follows.
Regular expressions can contain both special and ordinary characters.
You can concatenate ordinary characters, so ' last ' matches the characters 'last'. Special characters either stand for classes of ordinary characters, or affect how the regular expressions around them are interpreted. Matches the start of the string. However, if Python would recognize the resulting sequence, the backslash should be repeated twice. Characters can be listed individually, or a range is indicated by giving two characters and separating them by a '-'.