<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks

Book Review: Teach Yourself Regular Expressions in 10 Minutes by Ben Forta

"So you've got a problem, and you want to use Regular Expressions to solve it. Now you've got two problems." - Scott Hanselman

Although numerous languages (including the .NET languages like C#, VB.NET and Javascript) and tools (editors like VS.NET & EditPlus) support Regular Expressions, it is a daunting topic for developers due to its hieroglyphic & cryptic nature.

When I came across the book, SAMS Teach Yourself Regular Expressions in 10 Minutes I was a little put off by the boastful and exaggerated title. Although the title does serve well to make the subject less daunting, it is a nice marketing gimmick and the author reveals in the preface that it is a tutorial book organized into a series of easy-to-follow 10 10-minute lessons.

I took more time than 10 minutes to read through each of the 10 chapters and appendices and found it insightful & educative. The author follows a hands-on approach & a informal style to guide the reader gently through the arcane details of Regular Expressions. There are numerous examples (including an appendix on Regular Expression Solutions to Common Problems) and the detailed analysis of the patterns discussed helps developers to build the reasoning when they have to write their own patterns independently.

The book does a good job of familiarizing the reader with Regular Expression terminology like Ranges, Metacharacters ( including Class metacharacters), Repeating Matches (Interval, Greedy, Lazy), Position Matching, Subexpressions, Lookahead and Lookbehind, Embedding Conditions and also alerts the reader about the pitfalls involved. For instance, the range [A-z] (unlike [A-Z] which matches all uppercase characters from A to Z or [a-z] which matches all lowercase characters from a to z ) matches all characters between ASCII A to ASCII z AND it also includes characters such as [ and ^, which fall between Z and a in the ASCII table making it dangerous to use.

The author Ben Forta, covers the finer details well; like when he points that special metacharacters like - (hyphen) and ^ (caret) have multiple uses. - (hyphen) is only a metacharacter when used between [ and ]. Outside of a set, – is a literal and will match only - and ^ (caret) negates a set only if in a set (enclosed within [ and ]) and is the first character after the opening ]. Outside of a set, and at the beginning of a pattern, ^ matches the start of string.

Not all regular expression implementations are the same. There is an appendix that highlights differences between syntax and features of Regular Expressions in .NET languages, Visual Studio.NET and Javascript among other languages.

There is a Regular Expression Tester in various language versions available online for download from the book's home page. Content with the freely downloadable Regular Expression Designer that I have been using for a long time, I'm yet to try the Regular Expression Tester.

While there are numerous websites on Regular Expressions (my favorite being RegExLib.com) to learn from, I recommend this book as a good starting point to understand Regular Expressions well & be productive fast.

Labels: , ,

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

Posted by Anonymous Ben Forta | 4/06/2007 07:48:00 PM

Thanks for the review, I'm glad you found the book useful and informative.

--- Ben    


Post a Comment