Skip to main content

2018 | Buch

Regex Quick Syntax Reference

Understanding and Using Regular Expressions

insite
SUCHEN

Über dieses Buch

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.

Inhaltsverzeichnis

Frontmatter
Chapter 1. An Introduction to Regular Expressions
Abstract
I still remember my doomed encounters with regular expressions back when I tried to learn them. In fact, I took pride in not using regular expressions. I always found a long workaround or a code snippet. I projected and blamed my own lack of expertise on the hard readability of regular expressions. This process continued until I was ready to face the truth: regular expressions are powerful, and they can save you a lot of time and headache.
Zsolt Nagy
Chapter 2. Regex Syntax 101
Abstract
When learning a new tool, you always have to get started somewhere.
Zsolt Nagy
Chapter 3. Executing Regular Expressions
Abstract
Regular expressions can be used in different programming languages and text editors. As it is important to test your code in different environments, in this chapter you will get to know how to construct and execute regexes in your own environment.
Zsolt Nagy
Chapter 4. Visualizing Regex Execution Using Finite State Machines
Abstract
A regular expression is converted into code executed in a virtual machine. This virtual machine runs on the virtual machine of the host language or editor.
Zsolt Nagy
Chapter 5. Repeat Modifiers
Abstract
In Chapter 1 I explained that regular expressions are imperative. Imperative languages come with control structures. When developing software using a programming language, we use the following control structures:
Zsolt Nagy
Chapter 6. Character Sets and Character Classes
Abstract
The previous chapter introduced finite state machines to make regular expressions easier to understand. In this chapter, you will learn the tools you need to create more complex finite state machines to perform advanced pattern matching tasks with regular expressions.
Zsolt Nagy
Chapter 7. Substring Extraction from Regular Expressions
Abstract
You read about many different use cases of regular expressions in Chapter 1.
Zsolt Nagy
Chapter 8. Lookahead and Lookbehind
Abstract
Anchors such as ^, $, and the \b boundary character are zero-length assertions that filter matches based on special conditions. These conditions restrict the position of the first or last character of the match. We will now do something similar, but this time, we will restrict the position of some characters in the expression with respect to other characters in the string. Lookahead and Lookbehind are two zero-length assertions that accomplish this.
Zsolt Nagy
Chapter 9. Maintaining Regular Expressions
Abstract
There is a common fear in the industry of writing and maintaining regular expressions. This is because as an expression becomes bigger, reading it gets harder.
Zsolt Nagy
Chapter 10. Optimizing Regular Expressions
Abstract
You have learned all the tools to optimize the execution of a regular expression; therefore, this chapter acts as a summary for everything you have learned so far.
Zsolt Nagy
Chapter 11. Parsing HTML Code and URL Query Strings with Regular Expressions
Abstract
In this chapter, we will use JavaScript to parse an HTML document and process the query string of a URL.
Zsolt Nagy
Backmatter
Metadaten
Titel
Regex Quick Syntax Reference
verfasst von
Zsolt Nagy
Copyright-Jahr
2018
Verlag
Apress
Electronic ISBN
978-1-4842-3876-9
Print ISBN
978-1-4842-3875-2
DOI
https://doi.org/10.1007/978-1-4842-3876-9