Regular Expressions: Pocket Primer
Written by Alex Armstrong   

Author: Oswald Campesato
Publisher: Mercury Learning & Information
Date: July 2018
Pages: 190
ISBN: 978-1683922278
Print: 1683922271
Kindle: B07FK4NHWQ
Audience: Those who want to understand regexes
Rating: 3
Reviewer: Alex Armstrong
Regular expressions are tough to remember so a pocket primer sounds like a good idea.

We all know that regular expressions are useful but they also have a reputation for being difficult. The problem is partly that there are so many different symbols with slightly different meanings in different languages. Even in this web oriented day and age a pocket book that lets you find out the details you need seems like a good idea.

Banner

Chapter one deals with more less the whole idea of a regular expression. It does it by presenting sections that deal with "working with x" where x is some metacharacter or other. The is no background on the basic idea of a regular expression i.e. a type of grammar. It treats the problem as one of working your way though increasingly specialized metacharacters. I don't particularly like this approach but another reader might.

 Chapter 2 is a set of common examples - phone numbers, zip codes, email addresses and so on. For many readers this might well be the most valuable part of the book. It also introduces the idea of capture and back references which personally I consider to be the point at which regular expressions become truly complicated. I would have preferred a more focused look at the idea of capture and groups. The section on testing also got me excited - I've wanted to know how to test a regular expression for a long time. I still want to know.

 

The rest of the book consists of three chapters on each of the following languages - Python,  R and bash. There are also two appendices on Perl and Java. It does make sense to deal with the idiosyncrasies of particular language implementations of regular expressions but what about JavaScript or C#?

It is also generally held that Perl, Java and Python use a regular expression syntax that is very close. The bash syntax or more accurately the POSIX regular expression syntax is the big alternative and also used by C and C++. I think there might be a better way to summarize the variations in regular expressions across languages.

Conclusion

This is a book packed with lots of examples and, even better, useful examples. It doesn't really manage to make regular expressions simpler to understand, however. There is a lot of logic behind how regular expression work and this isn't made particularly clear. A pocket primer probably should have lots of tables and charts summarizing how things work and this one doesn't. The final chapters, focusing on different languages are, of course, only going to be useful if the languages are ones you use.

This isn't a bad book but it is one that is likely to be useful only to a very specific group of readers. Writing a really good book on regular expressions is probably much harder than it seems.

 

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.

Banner


Introducing SQL Server 2019 (Packt)

Author: Kellyn Gorman et al
Publisher: Packt Publishing
Pages: 488
ISBN: 978-1838826215
Print: 1838826211
Kindle: B088BNMRQ4
Audience: SQL Server DBAs and Devs
Rating: 3
Reviewer: Ian Stirk

Each new version of SQL Server introduces new features and enhances others. This book aims to discuss some of these [ ... ]



PHP In Easy Steps, 4th Ed

Author: Mike McGrath
Publisher: In Easy Steps
Date: April 2021
Pages: 192
ISBN: 978-1840789232
Print: 1840789239
Kindle: B08ZSV3MNH
Audience: People wanting to learn PHP
Rating: 4
Reviewer: Ian Elliot
PHP isn't a fashionable language, but this doesn't mean it isn't worth learning.


More Reviews

Last Updated ( Friday, 30 November 2018 )