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


The Rust Programming Language, 2nd Ed

Author: Steve Klabnik and Carol Nichols
Publisher: No Starch Press
Date: June 2023
Pages: 560
ISBN: 978-1718503106
Print: 1718503105
Kindle: B0B7QTX8LL
Audience: Systems programmers
Rating: 4.8
Reviewer: Mike James

There's a new edition of what has become the standard text on Rust. Has it matured along with [ ... ]



Programming Kotlin Applications (Wrox)

Author:  Brett McLaughlin
Publisher: Wrox/Wiley
Pages: 384
ISBN: 978-1119696186
Print: 1119696186
Kindle: B08QCK4982
Audience: Beginning Kotlin Programmers.
Rating: 3
Reviewer: Alex Armstrong

Kotlin applications - what applications in particular?


More Reviews

Last Updated ( Friday, 30 November 2018 )