E-Book, Englisch, 156 Seiten
Nagy Regex Quick Syntax Reference
1. ed
ISBN: 978-1-4842-3876-9
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Understanding and Using Regular Expressions
E-Book, Englisch, 156 Seiten
ISBN: 978-1-4842-3876-9
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
This quick guide to regular expressions is a condensed code and syntax reference for an important programming technique. It demonstrates regex syntax in a well-organized format that can be used as a handy reference, showing you how to execute regexes in many languages, including JavaScript, Python, Java, and C#.
The Regex Quick Syntax Reference features short, focused code examples that show you how to use regular expressions to validate user input, split strings, parse input, and match patterns. Utilizing regular expressions to deal with search/replace and filtering data for backend coding is also covered.
You won't find any bloated samples, drawn out history lessons, or witty stories in this book. What you will find is a language reference that is concise and highly accessible. The book is packed with useful information and is a must-have for any programmer.
What You Will LearnFormulate an expression
Work with arbitrary char classes, disjunctions, and operator precedence
Execute regular expressions and visualize using finite state machines
Deal with modifiers, including greedy and lazy loops
Handle substring extraction from regex using Perl 6 capture groups, capture substrings, and reuse substrings
Who This Book Is For
If you have dealt with at least one programming language, chances are you know enough to understand regular expressions, and the examples in this book will help you develop proficiency.
Zsolt Nagy is a web development team lead, mentor and software engineer living in Berlin, Germany. He programs with JavaScript, Perl and other open source web technologies. Zsolt is also experienced in using and teaching regular expressions using these technologies. He writes a blog about lessons learned while solving complex problems, experimenting with technology and teaching other people on how to improve their skills. As a software engineer, he continuously challenges himself to stick to the highest possible standards.
Autoren/Hrsg.
Weitere Infos & Material
1;Table of Contents;4
2;About the Author;9
3;About the Technical Reviewer;10
4;Chapter 1: An Introduction to Regular Expressions;11
4.1;Why Are Regular Expressions Important?;11
4.2;What Are Regular Expressions?;12
4.3;Frustrations with Regular Expressions Arise from Lack of Taking Action;14
4.4;Regular Expressions Are Imperative;15
4.5;The Language Family of Regular Expressions;16
4.6;Summary;18
5;Chapter 2: Regex Syntax 101;19
5.1;Formulating an Expression;19
5.1.1;Literal Characters and Meta Characters;20
5.2;Arbitrary Character Class;23
5.3;Basic Concatenation;24
5.4;Alternative Execution;24
5.5;Operator Precedence and Parentheses;25
5.6;Anchored Start and End;25
5.7;Modifiers;29
5.8;Summary;31
6;Chapter 3: Executing Regular Expressions;32
6.1;Regular Expressions in JavaScript;32
6.1.1;RegExp Methods;34
6.1.2;String Methods Accepting Regular Expressions;35
6.1.3;Regex Modifiers;36
6.1.4;Global Matches;37
6.1.5;Multiline Matches;39
6.1.6;ES6 Unicode Regular Expressions;40
6.1.7;Sticky Matches;41
6.1.8;Summary;43
6.2;Other PCRE-Based Regex Environments;43
6.2.1;PHP;44
6.2.2;Python;46
6.2.3;Perl 5;49
6.2.4;Java;50
6.2.5;R;52
6.2.6;C#;53
6.2.7;Ruby;55
6.2.8;Golang;57
6.2.9;C++;58
6.2.10;Summary;60
7;Chapter 4: Visualizing Regex Execution Using Finite State Machines;61
7.1;Regular Expressions Are Finite State Machines;61
7.2;Backtracking;63
7.3;Deterministic and Nondeterministic Regex Modeling;64
7.4;Basic Regex Simplifications;70
7.5;A Successful Match Is Cheaper Than Failure;71
7.6;Automatically Generating Regex FSMs;71
7.7;Summary;74
8;Chapter 5: Repeat Modifiers;75
8.1;Backtracking;76
8.2;Match at Least Once;78
8.3;Match at Most Once: Optionals;80
8.4;Match Any Number of Times;81
8.5;Fixed-Range Matching;82
8.6;Loop Exactly n Times;85
8.7;Greedy Repeat Modifiers;86
8.8;Lazy Repeat Modifiers;87
8.9;Possessive Repeat Modifiers;90
8.10;Summary;92
9;Chapter 6: Character Sets and Character Classes;93
9.1;Character Sets;93
9.2;Character Set Ranges;95
9.3;Exclusions from Character Sets;96
9.4;Character Set Classes;96
9.5;Concatenating Advanced Language Constructs;100
9.6;Summary;101
10;Chapter 7: Substring Extraction from Regular Expressions;102
10.1;Defining Capture Groups;103
10.2;Perl 6 Capture Groups;104
10.3;Retrieval of Captured Substrings;105
10.3.1;JavaScript;107
10.3.2;PHP;108
10.3.3;Python;109
10.3.4;Perl 5;110
10.4;Reusing Captured Substrings Within a Regex;111
10.5;Capture Groups and Performance;113
10.6;Extensions to Capture Groups;115
10.7;Summary;115
11;Chapter 8: Lookahead and Lookbehind;116
11.1;Lookahead;116
11.2;Lookbehind;119
11.3;Summary;120
12;Chapter 9: Maintaining Regular Expressions;121
12.1;Extended Mode;122
12.2;Regex Subroutines;124
12.2.1;PCRE Subroutines;125
12.2.2;Perl 6 Subroutines;126
12.2.3;Recursion and Circular References with Subroutines;127
12.2.4;Extended Mode, Subroutines, and Abstractions;127
12.3;Named Capture Groups;128
12.3.1;EMACS Named Capture Groups;128
12.3.2;PCRE Named Capture Groups;128
12.3.3;Perl 6 Named Capture Groups;131
12.4;Case Study: XRegExp Library for JavaScript;131
12.5;Summary;134
13;Chapter 10: Optimizing Regular Expressions;136
13.1;Summary of the Optimization Techniques;137
13.2;Making Character Classes More Specific;137
13.3;Repeating Character Class Loops;139
13.4;Use Possessive Repeat Modifiers Whenever Possible;140
13.5;Use Atomic Groups;141
13.6;Refactor for Optimization;143
13.7;Optimization Techniques Limit Nondeterministic Execution;143
13.8;Summary;144
14;Chapter 11: Parsing HTML Code and URL Query Strings with Regular Expressions;145
14.1;Parsing HTML Tags;145
14.2;Processing the Query String of a URL;148
15;Afterword: This Is Not the End, but the Beginning;150
15.1;“What If I Want to Learn More?”;152
15.2;Keep in Touch;153
16;Index;154




