Chapter 1. Regular Expressions

Some people, when confronted with a problem, think, “I know, I’ll use regular expressions.” Now they have two problems.

—Jamie “jwz” Zawinski, August 1997

In this chapter...

Introduction/Motivation

Special Symbols and Characters

Regexes and Python

Some Regex Examples

A Longer Regex Example

1.1. Introduction/Motivation

Manipulating text or data is a big thing. If you don’t believe me, look very carefully at what computers primarily do today. Word processing, “fill-out-form” Web pages, streams of information coming from a database dump, stock quote information, news feeds—the list goes on and on. Because we might not know the exact text or data that we have programmed our machines to process, it becomes ...

Get Core Python Applications Programming, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.