Regular Expressions (version 3rd)
Basic Information
Author: [us] Jeffrey E. F. Friedl
Translator: Yu Sheng
Press: Electronic Industry Press
ISBN: 9787121175015
Mounting time:
Published on: February 1, August 2012
Start: 16
Page number: 560
Version: 1-1
Category: Computer> Software and programming> integration> advanced programming language design
More about"
Introduction
Books
Computer books
With the rapid development of the Internet, the regular expressions supported by almost all tool software and programming languages have become increasingly powerful and easy to use. This book is a classic example of regular expressions. This book mainly explains the characteristics and genre of regular expressions, the matching principle, the optimization principle, the practical know-how and the adjustment measures, and introduces the regular expressions in Perl, Java ,. net and PHP.
Regular Expressions (version 3rd) Since version 1st, we have been focusing on teaching readers to "think with regular expressions" to make them "proficient" regular expressions. This version provides an extensive description of PHP-related content, new features of java1.5 and java1.6. Anyone who has the opportunity to use regular expressions will benefit from this.
Directory
Regular Expressions (version 3rd)
Preface I
Chapter 1: getting started with Regular Expressions 1
Solve Problem 2
Regular Expression 4 as a programming language
Analogy with file name 4
Language-based analogy 5
Thinking framework of regular expressions 6
For readers with some experience 6
Retrieve text files: egrep 6
Egrep metacharacters 8
Row start and end 8
Character group 9
Match any character 11 with the point number
Multiple choice Structure 13
Case-insensitive 14
Word divider 15
Summary 16
Option 17
Other quantifiers: repeated occurrence 18
Brackets and reverse References 20
Magic escape 22
Basic knowledge development 23
Language differences 23
Target 23 of the Regular Expression
More example 23
Regular Expression terminology 27
Improvement status 30
Conclusion 32
Statement of the Family 33
Chapter 5: Getting Started example 35
About these examples 36
Perl getting started 37
Use regular expressions to match text 38
Move toward a more practical program 40
Side effects of successful match 40
Intricate Regular Expressions 43
Pause for a moment 49
Use regular expression to Modify text 50
Example: public letter generation program 50
Example: stock price trimming 51
Automatic edit operation 53
Email processing tool 53
Add a comma (,) 59 to the value using the view function.
Text-to-HTML conversion 67
Back to word repetition question 77
Chapter 3: Characteristics and genre overview of regular expressions 83
Walk 85 in the world of Regular Expressions
The origins of Regular Expressions 85
Initial Impression 91
Precautions and handling methods for regular expressions 93
Integrated Processing 94
Procedural processing and object-oriented processing 95
Find and replace 98
Search and replace 100 in other languages
Note and handling method: Summary 101
String, character encoding, and matching mode 101
String 101 as a regular expression
Character encoding 105
Unicode 106
Regular and matching modes 110
Frequently Used metacharacters and features 113
Character Expression 115
Character group and Related Structure 118
Anchor and other "zero-length assertions" 129
Comment and mode modifier 135
Group, capture, condition judgment and control 137
Advanced topic guidance 142
Chapter 2: expression matching principle 4th
Engine launch 143
Two engines 144
New Standard 144
Regular Expression Engine classification 145
Digress 146
Test Engine type 146
Matching basics 147
Example 147
Rule 1: first select the leftmost matching result 148
Engine construction 149
Rule 2: Standard quantifiers give priority to 151 of matching
Expression-dominated and text-dominated 153
NFA engine: expression dominated by 153
DFA engine: Text dominated 155
First Thought: Compare NFA with DFA 156
Backtracking 157
Example in the Real World: bread chips 158
Two key points of backtracking 159
Backup status 159
Backtracing and matching give priority to 162
More about matching priority and backtracking: 163
Matching priority issue 164
Multi-character "citation" 165
Ignore quantifiers 166
Both matching priority and ignoring priority are expected to get matching 167.
Purpose of priority matching, ignore priority, and backtracing 168
Take precedence quantifiers and cure group 169
Take precedence quantifiers ,? +, * +, ++, And {m, n} + 172
Tracing 173 in the loop View
Is the multi-choice structure the priority of matching? 174
Discover the value of an ordered multiple-choice structure by 175
NFA, DFA, and POSIX 177
The leftmost longest rule is 177.
POSIX and leftmost longest Rule 178
Speed and efficiency 179
Conclusion: Comparison between NFA and DFA: 180
Conclusion 183
Chapter 2: Practical Skills of Regular Expressions 5th
Regular Expression balance Rule 186
Several simple examples 186
Match continuous rows (before continued) 186
IP address matching 187
Processing file name 190
Matching symmetric parentheses 193
Defense against unexpected match 194
Match text 196 in the delimiter
Understanding data and making assumptions 198
Removes the leading and trailing spaces of the text by 199 characters.
HTML example 200
Match HTML Tag 200
Matching HTML link 201
Check http url 203
Verify hostname 203
Extract URL 206 in the real world
Extension example 208
209 data coordination
Parsing CSV file 213
Chapter 2: Creating efficient regular expressions 6th
Example 222
Slightly modify -- the best leg 223
Efficiency vs. accuracy 223
Moving forward -- limits matching priority to 225
Actual measurement 226
Comprehensive Review 228
Posix nfa needs more processing 229
230 of the work that must be performed when the matching fails.
A little clear: 231
The cost of multiple-choice structures is 231 High.
Performance testing 232
Measure object 234
PHP testing 234
Java test 235
VB.net test 237
Ruby testing 238
Test Python 238
TCL testing 239
Common optimization measures 240
240 loss if possible
The optimization varies by 241
Application Principle of Regular Expressions 241
Optimization Measures before application 242
Optimized by 246 through transmission device
Optimize the regular expression itself 247
How to increase the expression speed by 252
Common sense optimization 254
Separate text 255
256 independent of the anchor.
Ignore or match first? Specific analysis 256
Split the regular expression 257
Simulate start Character Recognition 258
Use a fixed group and take precedence of 259
Matching of dominant engines: 260
Eliminate loop 261
Method 1: Build a regular expression 262 based on experience.
The true "Elimination of loops" solution 264
Method 2: top-down angle 266
Method 3: Match host name 267
Observe 268
Use a fixed group and take precedence of 268
Example 270
Eliminate c-language annotation matching cycle 272
Smooth Operation expression 277
Tool for bootstrap matching 277
A good regular expression is faster than 279.
Completion 281
Conclusion: Start your brain 281
Chapter 2: Perl 7th
Regular Expression 285 as a language component
Perl Strengths: 286
Perl's weaknesses: 286
Perl Regular Expression genre 286
Regular operators and regular text 288
Regular text Parsing Method 292
Regular modifier 292
Perl principles related to regular expressions 293
Expression application 294
Dynamic scope and regular expression matching effect 295
Match the modified special variable 299
Qr /... /Operator and RegEx object 303
Build and use RegEx object 303
Explore RegEx object 305
Improved efficiency by 306 using RegEx objects
Match operator 306
Match Regular Expression RMB 307
Specify the target operation RMB 308
Different uses of the match operator 309
Iterative Matching: scalar context,/g 312
Relationship between the match operator and the Environment 316
Substitution operator 318
Operation element replacement 319
/E modifier 319
Application Scenario and return value 321
Split operator 321
Basic knowledge about split 322
Returns an empty element 324.
Special RegEx operation in Split RMB 325
The match operator with captured parentheses in split is RMB 326
Use the proprietary features of Perl 326
Use a dynamic Regular Expression structure to match a nested structure 328
Use embedded code structure 331
Use the local function 335 in the embedded code structure
Advice on embedded code and my variable 338
Use embedded code to match the nested structure 340
Reload 341 of regular text
Reload of regular text 344
Simulate name capture 344
Efficiency 347
More than one 348 Method
Expression compilation,/o modifier, Qr /??? // And efficiency 348
Understanding "original" Replica 355
Study function 359
Performance testing 360
Regular Expression debugging information 361
Conclusion 363:
Chapter 2: Java 8th
Java Regular Expression genre 366
Java pair \ P {...} And \ P {...} 369
Unicode row Terminator 370
Use Java. util. RegEx 371
The pattern. Compile () Factory 372
Matcher method 373 of Pattern
Matcher object 373
Apply Regular Expression 375
Query matching result 376
Simple search-replacing 378
Advanced Search-replacing 380
Locate in situ-replace 382
Matcher search range: 384
Method chain 389
Build a scanner 389
Other methods of matcher 392
Other methods of pattern 394
The split method of pattern, with a single parameter of 395
The split method of pattern, two parameters: 396
Expansion example 397
Add the width and height attribute 397 for the Image Tag
For each matcher, use multiple pattern to verify HTML 399
Parsing CSV document 401
Java version difference 401
402 difference between 1.4.2 and 1.5.0
1.6 difference between 1.5.0 and 403
Chapter 2:. Net 9th
. Net regular expression genre 406
Supplement the genre by 409
Use a. net regular expression 413
Getting started with regular expressions 413
Packet overview 415
Core object overview 416
Core object explanation 418
Create RegEx object 419
Use RegEx object 421
Use the match object 427
Use Group Object 430
Static "convenient" function 431
Regular Expression caching 432
Function 432
. Net high-level topics 434
Regular Expression Assembly 434
Matching nested structure 436
Capture object 437
Chapter 2: PhP 10th
PHP Regular Expression genre 441
Preg function interface 443
"Pattern" parameter 444
Preg functions listed 449
Preg_match 449
Preg_match_all 453
Preg_replace 458
Preg_replace_callback 463
Preg_split 465
Preg_grep 469
Preg_quote 470
"Missing" preg function 471
Preg_regex_to_pattern 472
Perform a syntax check on the unknown pattern parameter 474
Syntax check for unknown Regular Expressions 475
Recursive Regular Expressions 475
Match text 475 in nested parentheses
It cannot be traced back to 477 of recursive calls.
Match a set of nested parentheses 478
Efficiency 478
Pattern modifier S: study 478
Extension example 480
Use PHP to parse CSV 480
Check the nested correctness of tagged data 481
Index 485
This book is from: China Interactive publishing network