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


Data Science with Java

Author:  Michael R. Brzustowicz
Publisher:  O'Reilly
Pages: 236
ISBN: 978-1491934111
Print: 1491934115
Kindle: B072MKRQBQ
Audience: Java programmers wanting to use the Apache Commons math library
Rating: 3
Reviewer: Alex Armstrong

 

Java is a candidate for doing data science, so a book [ ... ]



The Computing Universe

Author: Tony Hey and Gyuri Pápay
Publisher: Cambridge U P
Pages: 424
ISBN: 978-0521766456
Print: 0521150183
Kindle: B00N4PLZ5C
Audience: Anyone interested in the history of computing, in particular those studying computer science
Rating:  5
Reviewer: Sue Gee

A book with an ambi [ ... ]


More Reviews

Last Updated ( Friday, 30 November 2018 )