The Metacharacters

In all the examples that follow, the portions of text matched by patterns are represented with underlines. Remember that the entire target string is said to match even if just a portion of it matches the regular expression. The underline marks are to help demonstrate exactly what part of the target they match.

It's important to read through the following sections; however, don't worry if the information doesn't immediately make sense; it will shortly. The application of these metacharacters will be demonstrated in a bit.

A Simple Metacharacter

The first of the metacharacters is the dot (.). Inside a regular expression, the dot matches any single character except a newline character. For example, in the pattern /p.t/, the

Get SAMS Teach Yourself Perl in 24 Hours THIRD 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.