Lesson 5
Repeating Matches
In the previous lessons, you learned how to match individual characters using a variety of metacharacters and special class sets. In this lesson, you’ll learn how to match multiple repeating characters or sets of characters.
How Many Matches?
You’ve learned all the basics of regular expression pattern matching, but all the examples have had one very serious limitation. Consider what it would take to write a regular expression to match an email address. The basic format of an email address looks something like the following:
text@text.text
Using the metacharacters discussed in the previous lesson, you could create a regular expression like the following:
\w@\w\.\w
The \w
would match all alphanumeric characters (plus ...
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.