REVIEW - Java Regular Expressions - Taming the java.util.regex Engine


Java Regular Expressions

Taming the java.util.regex Engine


Mehran Habibi


Apress (2003)




Christer Lofving


February 2007



This is maybe the first book from Apress that I DO not really like.

Even a brief look around the pages reveals that the author must have been either short of material, or there was a narrow deadline to keep.

Maybe both of them? Because something of a world record in spaces and abundant code must have been hit here. For example, the print out function being identical all the time, is being repeated at the end of every example.

Furthermore, because it's Java this is about, and because the target group is not novices, in most cases 5-10 lines of code would be sufficient. Instead 1-2 pages are used for every single code sample. Even worse is that some of the introducing examples import abundant code. For example you can find this

import java.util.regex.*;
Note that the imported-by-default
is enough to compile and run the actual sample! Can seem to be trivial, but is still confusing when learning a new Java concept.

An other known trick to increase the number of pages is to copy-and-paste a language API, and pretend it to be a chapter of its own. That trick is tried here at least half ways. The

API is inserted after a very long introductory chapter. However, some useful explanations for that package are included, not to be found found in the original Javadoc.

Still, there are glimpses of light in the book. There are accurate and detailed step by step explanations following all regex syntax. And the pedagogic approach to advance from very simple to finally advanced examples is a good one. Maybe many of the problems are not about the content itself? One rather gets the feeling of a movie uncut by the director, or why not a manuscript released while still being a draft.

The topic at hand, the excellent support for regular expressions from Java 1.4 is appealing indeed. An alternative (and cheap) way of learning regular expressions is to use the excellent, free tutorials on If you want a book, Mastering Regular Expressions from O'Reilly is the Bible. Now in its third edition (2006) and expanded to include special chapters for Perl, NET, Java and more.

At the best Java Regular Expressions is a complement when learning regular expressions, but not more.

Book cover image courtesy of Open Library.

Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED

By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED

Settings can be changed at any time from the Cookie Policy page.