O'Reilly logo

Mastering Regular Expressions, 3rd Edition by Jeffrey E.F. Friedl

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Table of Contents

Preface

1: Introduction to Regular Expressions

Solving Real Problems

Regular Expressions as a Language

The Filename Analogy

The Language Analogy

The Regular-Expression Frame of Mind

If You Have Some Regular-Expression Experience

Searching Text Files: Egrep

Egrep Metacharacters

Start and End of the Line

Character Classes

Matching Any Character with Dot

Alternation

Ignoring Differences in Capitalization

Word Boundaries

In a Nutshell

Optional Items

Other Quantifiers: Repetition

Parentheses and Backreferences

The Great Escape

Expanding the Foundation

Linguistic Diversification

The Goal of a Regular Expression

A Few More Examples

Regular Expression Nomenclature

Improving on the Status Quo

Summary

Personal Glimpses

2: Extended Introductory Examples

About the Examples

A Short Introduction to Perl

Matching Text with Regular Expressions

Toward a More Real-World Example

Side Effects of a Successful Match

Intertwined Regular Expressions

Intermission

Modifying Text with Regular Expressions

Example: Form Letter

Example: Prettifying a Stock Price

Automated Editing

A Small Mail Utility

Adding Commas to a Number with Lookaround

Text-to-HTML Conversion

That Doubled-Word Thing

3: Overview of Regular Expression Features and Flavors

A Casual Stroll Across the Regex Landscape

The Origins of Regular Expressions

At a Glance

Care and Handling of Regular Expressions

Integrated Handling

Procedural and Object-Oriented Handling

A Search-and-Replace Example

Search and Replace in Other Languages ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required