Lesson 4

Using Metacharacters

Metacharacters were introduced in Lesson 2, “Matching Single Characters.” In this lesson you’ll learn about additional metacharacters used to match specific characters or character types.

Escaping Revisited

Before venturing deeply into the world of metacharacters, it is important to revisit a topic mentioned in passing previously: escaping.

Metacharacters are characters that have special meaning within regular expressions. The period (.) is a metacharacter; it is used to match any single character (as explained in Lesson 2). Similarly, the left bracket ([) is a metacharacter; it is used to mark the beginning of a set (as explained in Lesson 3, “Matching Sets of Characters”).

Because metacharacters take on special ...

Get Learning Regular Expressions, First 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.