Thus, complex expressions can easily be constructed from simpler primitive expressions like the ones described here. For details of the theory and implementation of regular expressions, consult the Friedl book referenced below, or 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 string ' last' . Special characters either stand for classes of ordinary characters, or affect how the regular expressions around them are interpreted. In the default mode, this matches any character except a newline. Causes the resulting RE to match from m to n repetitions of the preceding RE, attempting to match as few repetitions as possible. This is the non-greedy version of the previous qualifier.