Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Michael Fitzgerald

Rating No ratings yet

If you’re a programmer new to regular expressions, this easy-to-follow guide is a great place to start. You’ll learn the fundamentals step-by-step with the help of numerous examples, discovering first-hand how to match, extract, and transform text by matching specific words, characters, and patterns. Regular expressions are an essential part of a programmer’s toolkit, available in various Unix utlilities as well as programming languages such as Perl, Java, JavaScript, and C#. When you’ve finished this book, you’ll be familiar with the most commonly used syntax in regular expressions, and you’ll understand how using them will save you considerable time. Discover what regular expressions are and how they work Learn many of the differences between regular expressions used with command-line tools and in various programming languages Apply simple methods for finding patterns in text, including digits, letters, Unicode characters, and string literals Learn how to use zero-width assertions and lookarounds Work with groups, backreferences, character classes, and quantifiers Use regular expressions to mark up plain text with HTML5

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on, example-driven introduction to regular expressions for programmers who have never used them, teaching you to match, extract, and transform text across command-line tools and languages. Best for beginners who want practical fluency fast, not a reference for experts. 【Book Arc】 - **Opening (~0%–10%)**: Frames what regex is, why it belongs in a programmer's toolkit, and sets up the Unix/Linux tooling (Cygwin, BSD/Darwin) and practice files you'll need. - **Early (~10%–30%)**: Builds core matching skills through Regexpal/RegExr — string literals, digits, letters, word/non-word characters, whitespace, and the first quantifiers, using a phone-number example as the running exercise. - **Middle (~30%–50%)**: Moves into anchors and boundaries (`^`, `$`, `\b`, `\B`, `\A`, `\Z`), then applies them to real text by marking up a poem with HTML5 tags using sed and Perl. - **Late (~50%–80%)**: Covers the structural power tools — alternation, subpatterns, capturing/named/non-capturing/atomic groups, backreferences, and character classes including negated, union/difference, and POSIX classes. - **Ending (~80%–100%)**: Extends matching beyond ASCII into Unicode characters, octal escapes, and Unicode character properties, with appendices documenting tool-specific regex features. 【Key Takeaways】 - **Regex is a transferable skill, not a language feature** (Early): the same core syntax appears in Unix utilities and in Perl, Java, JavaScript, and C#, though the book stresses that dialects differ meaningfully. - **Character shorthands compress common patterns** (Early): `\d`, `\D`, `\w`, `\W`, `\s`, `\S` replace verbose character classes like `[0-9]` or `[a-zA-Z0-9]`, making expressions shorter and more readable. - **Quantifiers control repetition, and they're where beginners over-match** (Early): `?`, `+`, `*`, and `{m,n}` let you tune how many times something repeats; the phone-number example shows how a loose quantifier matches unintended digit groups. - **Anchors and boundaries are zero-width assertions** (Middle): `^`, `$`, `\b`, and `\B` match positions, not characters — a subtle but essential mental model for precise matching. - **Groups do double duty: structure and capture** (Late): parentheses cluster subpatterns for quantifiers and capture text for backreferences, while named, non-capturing, and atomic groups offer control over that behavior. - **Character classes are the workhorse for "any of these" matching** (Late): negated classes, union/difference, and POSIX classes give fine-grained control over what a single position accepts. - **Regex reaches beyond English text** (Ending): Unicode code points, octal escapes, and Unicode character properties let you match international and special characters, not just ASCII. - **Practice beats reading** (Early): the book repeatedly insists that regex only sticks if you run the examples yourself, and it points to a GitHub repo and downloadable example archive. 【Reading Tips】 - **Deep-read the early chapters and type every example** — the phone-number progression is the book's teaching spine; skimming it will cost you later. - **Skim the tool-installation and version-check passages** (Perl setup, Cygwin notes) unless you're actually configuring an environment; they're scaffolding, not concepts. - **Treat the sed/Perl markup chapter as a bridge, not a destination** — its value is showing regex in real pipelines; you don't need to master either tool here. - **Slow down on zero-width assertions and groups** — these are the two conceptual cliffs; re-read them with a live tester open. - **Keep a cheat sheet of shorthands and quantifiers** as you go; the book's strength is incremental syntax, and consolidation helps retention. 【Coverage Limits】 This guide is based on stratified excerpts covering the front matter, table of contents, and early-to-middle chapters; the later chapters on groups, character classes, and Unicode are summarized from headings and brief fragments, so specific examples there are not detailed. The excerpts do not cover the appendices' full technical tables or the book's complete exercise set.
Page 4
to Illustrator: Rebecca Demarest July 2012: First Edition. Revision History for the First Edition: 2012-07-10 First release See http://oreilly.com/catalog/er...
View in text
Page 16
ou to the Regexpal website at http://www.regexpal.com. Open the site up in a browser, such as Google Chrome or Mozilla Firefox. You can see what the site loo...
View in text
Excerpt 3
aracters, while \w does not—it matches letters and numbers. In English, \w matches essentially the same thing as the character class: [a-zA-Z0-9] You’ll lear...
View in text
Excerpt 4
es when the literal e is surrounded by non-word boundaries. In some applications, another way for specifying a word boundary is with: for the beginning of a...
View in text
Excerpt 5
g aspect of the state of regular expressions is that termi- nology, while usually close in meaning, can also range far. In defining subpattern and other term...
View in text
Excerpt 6
er who kept an ASCII code chart in his wallet. Just in case. The ASCII Code Chart: Don’t leave home without it. So I won’t gainsay the importance of ASCII, b...
View in text
Excerpt 7
ional) +? Lazy one or more *? Lazy zero or more {n}? Lazy n {n,}? Lazy n or more {m,n}? Lazy m,n Possessive Quantifiers A possessive match is like a greedy m...
View in text
Excerpt 8
he first line of the file and captures the entire line in a capturing group using escaped parentheses \( and \). sed needs to escape the paren- theses used t...
View in text
Tags
AI categories
Programming LanguageSoftwareEducation
ISBN: 1449392687
Publisher: O'Reilly Media
Publish Year: 2012
Language: English
Pages: 154
File Format: PDF
File Size: 8.7 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…