Introducing Regular Expressions

Introducing Regular Expressions

by Michael Fitzgerald


$44.99 $49.99 Save 10% Current price is $44.99, Original price is $49.99. You Save 10%.
View All Available Formats & Editions
Choose Expedited Shipping at checkout for guaranteed delivery by Wednesday, November 27


If you’re a programmer new to regular expressions, this easy-to-follow guide is a great place to start. You’ll learn the fundamentals step-by-step with the help of numerous examples, discovering first-hand how to match, extract, and transform text by matching specific words, characters, and patterns.

Regular expressions are an essential part of a programmer’s toolkit, available in various Unix utlilities as well as programming languages such as Perl, Java, JavaScript, and C#. When you’ve finished this book, you’ll be familiar with the most commonly used syntax in regular expressions, and you’ll understand how using them will save you considerable time.

  • Discover what regular expressions are and how they work
  • Learn many of the differences between regular expressions used with command-line tools and in various programming languages
  • Apply simple methods for finding patterns in text, including digits, letters, Unicode characters, and string literals
  • Learn how to use zero-width assertions and lookarounds
  • Work with groups, backreferences, character classes, and quantifiers
  • Use regular expressions to mark up plain text with HTML5

Product Details

ISBN-13: 9781449392680
Publisher: O'Reilly Media, Incorporated
Publication date: 08/02/2012
Pages: 154
Sales rank: 1,219,162
Product dimensions: 6.80(w) x 9.10(h) x 0.50(d)

About the Author

Michael Fitzgerald describes Ruby as "my favorite language so far" and is working regularly with Ruby and the Rails framework. He has written over 150 Ruby programs for testing and demonstration, and has been developing a library of sample Ruby code. He is the author of Learning XSLT and XML Hacks, and co-author on the XML Pocket Reference.

Table of Contents

Who Should Read This Book;
What You Need to Use This Book;
Conventions Used in This Book;
Using Code Examples;
Safari® Books Online;
How to Contact Us;
Chapter 1: What Is a Regular Expression?;
1.1 Getting Started with Regexpal;
1.2 Matching a North American Phone Number;
1.3 Matching Digits with a Character Class;
1.4 Using a Character Shorthand;
1.5 Matching Any Character;
1.6 Capturing Groups and Back References;
1.7 Using Quantifiers;
1.8 Quoting Literals;
1.9 A Sample of Applications;
1.10 What You Learned in Chapter 1;
1.11 Technical Notes;
Chapter 2: Simple Pattern Matching;
2.1 Matching String Literals;
2.2 Matching Digits;
2.3 Matching Non-Digits;
2.4 Matching Word and Non-Word Characters;
2.5 Matching Whitespace;
2.6 Matching Any Character, Once Again;
2.7 Marking Up the Text;
2.8 What You Learned in Chapter 2;
2.9 Technical Notes;
Chapter 3: Boundaries;
3.1 The Beginning and End of a Line;
3.2 Word and Non-word Boundaries;
3.3 Other Anchors;
3.4 Quoting a Group of Characters as Literals;
3.5 Adding Tags;
3.6 What You Learned in Chapter 3;
3.7 Technical Notes;
Chapter 4: Alternation, Groups, and Backreferences;
4.1 Alternation;
4.2 Subpatterns;
4.3 Capturing Groups and Backreferences;
4.4 Non-Capturing Groups;
4.5 What You Learned in Chapter 4;
4.6 Technical Notes;
Chapter 5: Character Classes;
5.1 Negated Character Classes;
5.2 Union and Difference;
5.3 POSIX Character Classes;
5.4 What You Learned in Chapter 5;
5.5 Technical Notes;
Chapter 6: Matching Unicode and Other Characters;
6.1 Matching a Unicode Character;
6.2 Matching Characters with Octal Numbers;
6.3 Matching Unicode Character Properties;
6.4 Matching Control Characters;
6.5 What You Learned in Chapter 6;
6.6 Technical Notes;
Chapter 7: Quantifiers;
7.1 Greedy, Lazy, and Possessive;
7.2 Matching with *, +, and ?;
7.3 Matching a Specific Number of Times;
7.4 Lazy Quantifiers;
7.5 Possessive Quantifiers;
7.6 What You Learned in Chapter 7;
7.7 Technical Notes;
Chapter 8: Lookarounds;
8.1 Positive Lookaheads;
8.2 Negative Lookaheads;
8.3 Positive Lookbehinds;
8.4 Negative Lookbehinds;
8.5 What You Learned in Chapter 8;
8.6 Technical Notes;
Chapter 9: Marking Up a Document with HTML;
9.1 Matching Tags;
9.2 Transforming Plain Text with sed;
9.3 Appending Tags;
9.4 Transforming Plain Text with Perl;
9.5 What You Learned in Chapter 9;
9.6 Technical Notes;
Chapter 10: The End of the Beginning;
10.1 Learning More;
10.2 Notable Tools, Implementations, and Libraries;
10.3 Matching a North American Phone Number;
10.4 Matching an Email Address;
10.5 What You Learned in Chapter 10;
Regular Expression Reference;
Regular Expressions in QED;
Character Shorthands;
Unicode Whitespace Characters;
Control Characters;
Character Properties;
Script Names for Character Properties;
POSIX Character Classes;
ASCII Code Chart with Regex;
Technical Notes;
Regular Expression Glossary;

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews

Introducing Regular Expressions 4 out of 5 based on 0 ratings. 1 reviews.
FantasyRider More than 1 year ago
Fitzgerald Does Not Disappoint I read Introducing Regular Expressions: Unraveling regular expressions, step-by-step by Michael Fitzgerald to gather deeper insights into the details behind regular expressions. Fitzgerald does not disappoint. The reader should sit back and prepare to drink from the fire hose as Fitzgerald drives through regular expressions in many of their entry level flavors and styles. Introducing Regular Expressions is not for the faint of heart as the reader must navigate lots of regex simulator tools and platforms in order to practice the examples that Fitzgerald fires at the reader without mercy. If the reader is prepared for a no fluff introduction into regular expressions, then this book is for them. The reader must be prepared for the technical hurdles needed to execute the samples provided in the book. Fitzgerald has the reader execute regex in toolsets such as sed, grep, perl, Cygwin, vi, ack, vim, and even more regex simulation tools. The tool setups can quickly become a distraction to the reader as they spend more time bouncing between tools than actually understanding at depth the reasons behind the samples themselves. However, as long as the reader takes the time to work through the tools and samples, they will not only gain knowledge in regular expressions, but also many common toolsets. At its heart, this toolset requirement demonstrates to the astute reader an understanding that unlike many IT “languages” there is no single regular expression structure or behavior. Demonstrating that you may have to customize your use based on the tools you choose. Overall, I’d recommend this book for two main reader types. The first is for the reader that is looking to understand the overall behaviors and traits of regular expressions without a 500 page manual with lots of fluff. The second is for the reader that has a basic understanding of regular expressions but would like a quick reference on why the expressions work the way they do in many cookbook and internet examples.