viii Table of Contents
AFew MoreExamples ............................................................................... 23
Regular Expression Nomenclature............................................................ 27
Impr oving on the Status Quo .................................................................... 30
Summary ..................................................................................................... 32
Personal Glimpses ............................................................................................ 33
2: Extended Introductor y Examples .......................................................... 35
About the Examples .......................................................................................... 36
AShort Introduction to Perl ...................................................................... 37
Matching Text with Regular Expressions ......................................................... 38
Toward a MoreReal-World Example ........................................................ 40
Side Effects of a Successful Match ............................................................ 40
Intertwined Regular Expressions ............................................................... 43
Inter mission ................................................................................................ 49
Modifying Text with Regular Expressions ....................................................... 50
Example: FormLetter ................................................................................. 50
Example: Prettifying a Stock Price ............................................................ 51
Automated Editing ...................................................................................... 53
ASmall Mail Utility ..................................................................................... 53
Adding Commas to a Number with Lookaround ..................................... 59
Text-to-HTML Conversion ........................................................................... 67
That Doubled-Word Thing ......................................................................... 77
3: Over viewofRegular Expression Features and Flavors ................ 83
ACasual Stroll Across the Regex Landscape ................................................... 85
The Origins of Regular Expressions .......................................................... 85
At a Glance ................................................................................................. 91
Car e and Handling of Regular Expressions ..................................................... 93
Integrated Handling ................................................................................... 94
Pr ocedural and Object-Oriented Handling ............................................... 95
ASearch-and-Replace Example ................................................................. 98
Search and Replace in Other Languages ................................................ 100
Car e and Handling: Summary ................................................................. 101
Strings, Character Encodings, and Modes ...................................................... 101
Strings as Regular Expressions ................................................................ 101
Character-Encoding Issues ....................................................................... 105
Unicode ..................................................................................................... 106
Regex Modes and Match Modes .............................................................. 110
Common Metacharacters and Features .......................................................... 113
7July 2006 21:51
- 1
- 2
前往页