Masting Python Regular Expressions
The book, short and sweet as it is, still has space to devote the first chapter to the history of regular expressions, not failing to mention the grep trivia. After the history is history, it moves on to cover, at first, the basics, including building patterns and match objects. Next it moves into slightly more advanced territory with groups and backreferencing. The most advanced features covered are matching with look ahead and look behind, both positive and negative. It finishes up with some tips on optimization and the advice to not prematurely optimize.