When I saw the title of this book, I was excited at the prospect of a book filled with detailed regular expression examples. Unfortunately, it didn't pan out that way.
Spread over 285 pages, the book lists exactly 100 tasks that you can accomplish with a regular expression. As the solution, the author not only gives a regular expression, but also a complete source code snippet in Perl. Most of the recipes also show the same solution (using the same regular expression) in a different programming language. Many recipes have solutions in PHP or Python. Some also have solutions for Vim (a UNIX text editor) and UNIX shell scripting.
Obviously, the examples have a heavy bias towards UNIX and open source. If you're a Windows programmer, you may want to look at Regular Expression Recipies for Windows Programmers instead. It's essentially the same book, with almost the same list of recipes, but with the examples redone in C# and VB.
Each recipe also has a "how it works" section, essentially transcribing the regular expression in English, similar in approach to RegexBuddy's plain English regex trees, though the book uses a flat description rather than a tree.
Most of the recipes solve rather basic problems, organized in six chapters. The first, "Words and Text", deals with finding blank lines, repeated words, words at the start or end of a line, etc. The "URLs and Paths" chapter has examples for finding URLs and file paths, and extracting bits from them. The "CSV and tab-delimited files" has a few recipes for converting between the two and extracting fields.
The "Formatting and Validating" chapter shows how to validate numbers, currency, dates, phone numbers, addresses, etc. The "XML and HTML" chapter has recipes for matching and replacing tags and attributes. Finally, "Coding and Using Commands" has some recipes for manipulating source code files, and for parsing the results of various UNIX system commands.
The book would have been a better deal if it had focused on regular expressions and left out the many lines of Perl source code. Not to mention the fact that many examples have equivalent source code listings for PHP and/or Python as well. Without the source code, a book of the same size could easily contain 250 examples. That would have made it far more useful for programmers who know how to program, but aren't well-versed in regular expressions.
As it is, I can only recommend this book to people who are not only new to regular expressions, but also relatively new to programming. The book does contain many recipes that solve basic problems you're likely to encounter when writing scripts for a website in Perl, PHP or Python. If you happen to use one of these languages, and are looking for a cookbook approach, you'll certainly find the book useful.
But don't expect to really learn how regular expressions work from this book. If you develop software for a living, you're better of with a good regular expressions tutorial or a book like "Regular Expressions Cookbook".
Did this website just save you a trip to the bookstore? Please make a donation to support this site, and you'll get a lifetime of advertisement-free access to this site! Credit cards, PayPal, and Bitcoin gladly accepted.
Page URL: https://www.regular-expressions.info/bookrecipes.html
Page last updated: 21 September 2017
Site last updated: 22 September 2017
Copyright © 2003-2017 Jan Goyvaerts. All rights reserved.
|Regular Expr. Cookbook|
|Teach Yourself Reg. Expr.|
|Mastering Regular Expr.|
|Java Regular Expressions|
|Oracle Regular Expr.|
|Regular Expr. Pocket Ref.|
|Regular Expr. Recipes|
|Regex Recipes for Windows|
|Regular Expressions Quick Start|
|Regular Expressions Tutorial|
|Replacement Strings Tutorial|
|Applications and Languages|
|Regular Expressions Examples|
|Regular Expressions Reference|
|Replacement Strings Reference|
|About This Site|
|RSS Feed & Blog|