search for books and compare prices
Tables of Contents for Mastering Regular Expressions
Chapter/Section Title
Page #
Page Count
Preface
xv
 
1: Introduction to Regular Expressions
1
30
Solving Real Problems
2
2
Regular Expressions as a Language
4
2
The Filename Analogy
4
1
The Language Analogy
5
1
The Regular-Expression Frame of Mind
6
2
Searching Text Files: Egrep
7
1
Egrep Metacharacters
8
13
Start and End of the Line
8
1
Character Classes
9
2
Matching Any Character--Dot
11
1
Alternation
12
2
Word Boundaries
14
1
In a Nutshell
15
1
Optional Items
16
1
Other Quantifiers: Repetition
17
1
Ignoring Differences in Capitalization
18
1
Parentheses and Backreferences
19
1
The Great Escape
20
1
Expanding the Foundation
21
9
Linguistic Diversification
21
1
The Goal of a Regular Expression
21
1
A Few More Examples
22
2
Regular Expression Nomenclature
24
2
Improving on the Status Quo
26
2
Summary
28
2
Personal Glimpses
30
1
2: Extended Introductory Examples
31
28
About the Examples
32
2
A Short Introduction to Perl
33
1
Matching Text with Regular Expressions
34
11
Toward a More Real-World Example
36
1
Side Effects of a Successful Match
36
3
Intertwined Regular Expressions
39
4
Intermission
43
2
Modifying Text with Regular Expressions
45
14
Automated Editing
47
1
A Small Mail Utility
48
6
That Doubled-Word Thing
54
5
3: Overview of Regular Expression Features and Flavors
59
28
A Casual Stroll Across the Regex Landscape
60
3
The World According to Grep
60
1
The Times They Are a Changin'
61
2
At a Glance
63
3
POSIX
64
2
Care and Handling of Regular Expressions
66
4
Identifying a Regex
66
1
Doing Something with the Matched Text
67
1
Other Examples
67
3
Care and Handling: Summary
70
1
Engines and Chrome Finish
70
1
Chrome and Appearances
71
1
Engines and Drivers
71
1
Common Metacharacters
71
14
Character Shorthands
72
3
Strings as Regular Expressions
75
2
Class Shorthands, Dot, and Character Classes
77
4
Anchoring
81
2
Grouping and Retrieving
83
1
Quantifiers
83
1
Alternation
84
1
Guide to the Advanced Chapters
85
2
Tool-Specific Information
85
2
4: The Mechanics of Expression Processing
87
52
Start Your Engines!
87
3
Two Kinds of Engines
87
1
New Standards
88
1
Regex Engine Types
88
2
From the Department of Redundancy Department
90
1
Match Bascis
90
9
About the Examples
91
1
Rule 1: The Earliest Match Wins
91
1
The "Transmission" and the Bump-Along
92
1
Engine Pieces and Parts
93
1
Rule 2: Some Metacharacters Are Greedy
94
5
Regex-Directed vs. Text-Directed
99
3
NFA Engine: Regex-Directed
99
1
DFA Engine: Text-Directed
100
1
The Mysteries of Life Revealed
101
1
Backtracking
102
6
A Really Crummy Analogy
102
1
Two Important Points on Backtracking
103
1
Saved States
104
2
Backtracking and Greediness
106
2
More About Greediness
108
7
Problems of Greediness
108
1
Multi-Character "Quotes"
109
1
Laziness?
110
1
Greediness Always Favors a Match
110
2
Is Alternation Greedy?
112
1
Uses for Non-Greedy Alternation
113
1
Greedy Alternation in Perspective
114
1
Character Classes vs. Alternation
115
1
NFA, DFA, and POSIX
115
6
"The Longest-Leftmost"
115
1
POSIX and the Longest-Leftmost Rule
116
2
Speed and Efficiency
118
1
DFA and NFA in Comparison
118
3
Practical Regex Techniques
121
15
Contributing Factors
121
1
Be Specific
122
3
Difficulties and Impossibilities
125
2
Watching Out for Unwanted Matches
127
2
Matching Delimited Text
129
3
Knowing Your Data and Making Assumptions
132
1
Additional Greedy Examples
132
4
Summary
136
3
Match Mechanics Summary
136
1
Some Practical Effects of Match Mechanics
137
2
5: Crafting a Regular Expression
139
42
A Sobering Example
140
5
A Simple Change--Placing Your Best Foot Forward
141
1
More Advanced--Localizing the Greediness
141
3
Reality Check
144
1
A Global View of Backtracking
145
9
More Work for a POSIX NFA
147
1
Work Required During a Non-Match
147
1
Being More Specific
147
1
Alternation Can Be Expensive
148
1
A Strong Lead
149
1
The Impact of Parentheses
150
4
Internal Optimizations
154
4
First-Character Discrimination
154
1
Fixed-String Check
155
1
Simple Repetition
155
1
Needless Small Quantifiers
156
1
Length Cognizance
157
1
Match Cognizance
157
1
Need Cognizance
157
1
String/Line Anchors
158
1
Compile Caching
158
2
Testing the Engine Type
160
2
Basic NFA vs. DFA Testing
160
1
Traditional NFA vs. POSIX NFA Testing
161
1
Unrolling the Loop
162
6
Method 1: Building a Regex From Past Experiences
161
2
The Real "Unrolling the Loop" Pattern
164
2
Method 2: A Top-Down View
166
1
Method 3: A Quoted Internet Hostname
167
1
Observations
168
1
Unrolling C Comments
168
5
Regex Headaches
169
1
A Naive View
169
2
Unrolling the C Loop
171
2
The Freeflowing Regex
173
4
A Helping Hand to Guide the Match
173
1
A Well-Guided Regex is a Fast Regex
174
2
Wrapup
176
1
Think!
177
4
The Many Twists and Turns of Optimizations
177
4
6: Tool-Specific Information
181
18
Questions You Should Be Asking
181
2
Something as Simple as Grep
181
1
In This Chapter
182
1
Awk
183
5
Differences Among Awk Regex Flavors
184
3
Awk Regex Functions and Operators
187
1
Tcl
188
4
Tcl Regex Operands
189
1
Using Tcl Regular Expressions
190
2
Tcl Regex Optimizations
192
1
GNU Emacs
192
7
Emacs Strings as Regular Expressions
193
1
Emacs's Regex Flavor
193
3
Emacs Match Results
196
1
Benchmarking in Emacs
197
1
Emacs Regexz Optimizations
197
2
7: Perl Regular Expressions
199
110
The Perl Way
201
9
Regular Expressions as a Language Component
202
1
Perl's Greatest Strength
202
1
Perl's Greatest Weakness
203
1
A Chapter, a Chicken, and The Perl Way
204
1
An Introductory Example: Parsing CSV Text
204
3
Regular Expressions and The Perl Way
207
1
Perl Unleashed
208
2
Regex-Related Perlisms
210
15
Expression Context
210
1
Dynamic Scope and Regex Match Effects
211
6
Special Variables Modified by a Match
217
2
"Doublequotish Processing" and Variable Interpolation
219
6
Perl's Regex Flavor
225
21
Quantifiers--Greedy and Lazy
225
2
Grouping
227
5
String Anchors
232
4
Multi-Match Anchor
236
4
Word Anchors
240
1
Convenient Shorthands and Other Notations
241
2
Character Classes
243
2
Modification with /Q and Friends: True Lies
245
1
The Match Operator
246
9
Match-Operand Delimiters
247
2
Match Modifiers
249
1
Specifying the Match Target Operand
250
1
Other Side Effects of the Match Operator
251
1
Match Operator Return Value
252
2
Outside Influences on the Match Operator
254
1
The Substitution Operator
255
4
The Replacement Operand
255
2
The /e Modifier
257
1
Context and Return Value
258
1
Using /g with a Regex That Can Match Nothingness
259
1
The Split Operator
259
6
Basic Split
259
2
Advanced Split
261
1
Advanced Split's Match Operand
262
2
Scalar-Context Split
264
1
Split's Match Operand with Capturing Parentheses
264
1
Perl Efficiency Issues
265
25
"There's More Than One Way to Do It"
266
2
Regex Compilation, the /o Modifier, and Efficiency
268
5
Unsociable $& and Friends
273
5
The Efficiency Penalty of the /i Modifier
278
3
Substitution Efficiency Concerns
281
3
Benchmarking
284
1
Regex Debugging Information
285
2
The Study Function
287
3
Putting It All Together
290
14
Stripping Leading and Trailing Whitespace
290
1
Adding Commas to a Number
291
1
Removing C Comments
292
2
Matching an Email Address
294
10
Final Comments
304
5
Notes for Perl4
305
4
A: Online Information
309
4
B: Email Regex Program
313