Chapter 17. Regular expressions

This chapter covers

  • Understanding regular expressions
  • Creating regular expressions with special characters
  • Using raw strings in regular expressions
  • Extracting matched text from strings
  • Substituting text with regular expressions

In some sense, we shouldn’t discuss regular expressions in this book at all. They’re implemented by a single Python module and are advanced enough that they don’t even come as part of the standard library in languages like C or Java. But if you’re using Python, you’re probably doing text parsing; and if you’re doing that, then regular expressions are too useful to be ignored. If you use Perl, Tcl, or UNIX, you may be familiar with regular expressions; if not, this chapter will go into ...

Get The Quick Python Book, Second 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.