Regular Expressions Cookbook

September 24, 2010 · Posted in Bestselling Cooking Books 


Product Description
This O’Reilly Cookbook provides more than a hundred recipes to help programmers use regular expressions to manipulate text and crunch data. Every programmer needs a grasp of regular expressions, but their power doesn’t come without problems–even seasoned users often have trouble tackling performance issues. With recipes for popular programming languages such as C#, Java, JavaScript, Perl, PHP, Python, Ruby, and VB.NET, this book offers step-by-step solutions to sco… More >>

Regular Expressions Cookbook

Be Sociable, Share!

Comments

5 Responses to “Regular Expressions Cookbook”

  1. Bob Reselman on September 24th, 2010 1:54 pm

    As much as I hate to admit it, regular expressions are hard for me. My need to use them is situation specific and I never really took the time to master them conceptually. So, when it comes time create one, I have to grope around to figure out how to meet the need at hand.

    This book is really made for a person like me. The structure is problem-solution based. And, every problem is numbered in outline format. Thus, referencing back is an easy affair.

    Want to know how to find bold text in an HTML file? This book will tell you how.

    Want to learn how to split a sting using a regular expression? This book tells you how.

    The book discusses solutions generally and in language specifics. It supports C#, Java, Javascript, Ruby, Python, PHP, Perl, VB.NET…. the entire cast of the usual characters. (No pun intended.)

    The writing is clear. You can take things in a bit at a time. And, that some of the problems use those ‘hard to get concepts’, the topical discussions actually teach you the difficult concepts in a manner that is pretty easy to understand. Sometimes you might have to go over a section of few times to get full understanding. But the review is not a chore.

    This is a good, useful book. It’s helping me to become a better engineer. And believe me, I need all the help that I can get! 🙂
    Rating: 4 / 5

  2. Techie Evan on September 24th, 2010 2:39 pm

    This excellent book goes further and deeper than many tutorials on regular expressions. You might be surprised with some of the things you’ll learn from reading it.

    Unlike many cookbooks, this one doesn’t dive into the recipes right away. I thought this was a good call because regular expressions are a specialized topic, and most developers don’t work with regular expressions on a daily basis so they probably have to be reminded of the building block concepts and syntax, and get prepared for a discussion of more advanced features. Chapter One provides a list of recommended tools for working with regular expressions. Chapter 2 is a concise but very thorough discussion of building block and more advanced regular expression concepts (e.g., possessive quantifier or atomic grouping, named capturing groups, lookahead and lookbehind, etc.), including a discussion of differences in engine implementations and feature support. Chapter 3 is a hundred-plus page tutorial on how to work with regular expressions using different programming and scripting languages, including potential gotchas and workarounds. Chapters Four through Eight contain the recipes for solving real-world problems, with tips on how to improve an initial solution’s readability (e.g., use named capturing groups when possible, etc.) and/or efficiency.

    I was initially skeptical about the authors’ ambitious goal of covering so many regular expression flavors, thinking the discussions of differences in engine supported features might prove distracting. The book is written and organized so well, however, my fear did not materialize. In fact, I was pleasantly surprised to learn that: of the covered flavors, Microsoft’s DotNet regex engine supports some of the most advanced features.

    There’s not much to dislike about this book but if I were asked to suggest one or two things that might be of value-add to readers, I would suggest making available for download files containing appropriate subject strings for testing the book’s various recipes as a convenience to readers who learn best by doing and want to follow along as they read the recipes, and for the book to include, for easy reference, a feature-support comparison matrix of the covered flavors, much like the comparison table available in the regular-expressions.info website.
    Rating: 5 / 5

  3. John R. Vacca on September 24th, 2010 4:12 pm

    Do you regularly work with text on a computer? If you do, then this book is for you! Authors Jan Goyvaerts and Steven Levithan, have done an outstanding job of writing a book that shows you how you can use regular expressions in situations where people with limited regular expressions experience would normally say it can’t be done.

    Goyvaerts and Levithan, begin by explaining the role of regular expressions and introduce a number of tools that will make it easier to learn, create, and debug them. Next, the authors cover each element and feature of regular expressions, along with important guidelines for effective use. Then, they specify coding techniques and include code listings for using regular expressions in each of the programming languages covered by this book. They continue by focusing on recipes for handling typical user input, such as dates, phone numbers, and postal codes in various countries. Next, the authors explore common text processing tasks, such as checking for lines that contain or fail to contain certain words. Then, they show you how to detect integers, floating-point numbers, and several other formats for this kind of input. The authors continue by showing you how to take apart and manipulate the strings commonly used on the Internet and Windows systems to find things. Finally, the authors cover the manipulation of HTML, XML, comma-separated values (CSV), and INI-style configuration files.

    This most excellent book shows you everything you need to know about regular expressions, and then some, regardless of whether you are a programmer. More importantly, if you read this book cover to cover, you’ll become a world class chef of regular expressions.
    Rating: 5 / 5

  4. Brett Merkey on September 24th, 2010 6:41 pm

    §

    I was getting set to write a review of this book, when I happened to visit one of the blogs I regularly read — Coding Horror. Jeff Atwood says it all for me so please take a look at what he has to say.

    If you are a serious programmer or even if you are a Web GUI design person forced to do a bit of JavaScripting like me, you are going to run into situations where using a regex engine is the appropriate tool. Regular expressions are not easy to learn and are kind of boring. They are also very powerful.

    Most of us learn faster by doing — and that most often means working from code we or someone else has done before that does something a bit like what we want to do but needs some tweaking or extending or generalizing. If you are like me, you already have a collection of regular expressions to help in this process. This book does better than that by collecting hundreds of examples together in ways that build your understanding while never getting abstract or divorced from the real problems we face.

    Your shelf has a place for this book. Recommended.

    §
    Rating: 5 / 5

  5. Jerry Saperstein on September 24th, 2010 7:13 pm

    Jan Goyvaerts is well-known in the RegEx community; Steven Levithan somewhat less so. But the degree of fame is unimportant, both are Regular Expressions gurus and really know what they are talking about. Goyvaerts also writes and publishes some really cool software tools, including two for dealing with Regular Expressions.

    The last great book on Regular Expressions was “Mastering Regular Expressions” by Jeffrey E. F. Friedl, also published by O’Reilly. This book does not replace “Mastering Regular Expressions”, but complements it. Between the two volumes, you’ll know everything of importance worth knowing about Regular Expressions and their use.

    Regular Expressions are used to find specific patterns of text. For anyone working extensively with text of any kind, Regular Expressions are as necessary as water and air to sustaining human life. Most people never get behind the primitive search functions of their word processor or spreadsheet program. Too bad: they’re missing a lot.

    The ugly part of what they’re missing is learning how to use Regular Expressions.

    Conceptually, Regular Expressions are difficult for many people (like me) to grasp and even more difficult to learn. A big part of that is the staggering power of Regular Expressions (“regexp” or “regexes”). Want to a single search for specific words that are misspelled? Regex. How about sentences beginning or ending with specific words? Use a regex.

    In their cookbook, the authors demonstrate more than a hundred examples. Better yet, they do it in seven common regex flavors. The authors claim “Regular Expressions Cookbook” is all you know to learn how to use Regular Expressions. They do start with the basics, but I question whether this book is all most will need. I think consulting one of the many fine Regular Expression tutorials on the web might be a helpful first step for the utter novice.

    The cookbook itself is absolutely marvelous.

    There are more than one hundred recipes, beginning with matching literal text; advancing through matching previously matched text again; retrieving a list of all matches; validating formats of things like email addresses, international phone numbers, even European VAT numbers; finding words not preceded or followed by a specific word; and much more.

    This is, I short, a book for the true geek to curl up with and read. You may not need the information now, but you will need it someday and just browsing is an effective way to pick it up. Likewise, if you’re looking for an immediate solution to a problem right now, just check the Table Of Contents. Odds are you’ll find what you’re looking for or something real close. Sadly, however, the index isn’t very good.

    In short, this is the newest benchmark reference for Regular Expressions. With this and “Mastering Regular Expressions”, you are going to be a Master of the Universe and do things with text that will leave ordinary mortals awestruck.

    Jerry

    Rating: 5 / 5

Leave a Reply