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
Inhaltsverzeichnis
Preface;
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;
Acknowledgments;
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;
Metacharacters;
Character Shorthands;
Whitespace;
Unicode Whitespace Characters;
Control Characters;
Character Properties;
Script Names for Character Properties;
POSIX Character Classes;
Options/Modifiers;
ASCII Code Chart with Regex;
Technical Notes;
Regular Expression Glossary;
Colophon;